@@ -47,13 +47,13 @@ def start_thread
4747 connected = false
4848
4949 if @config . streaming_enabled
50- @config . logger . debug ( 'Starting Streaming mode ...' ) if @config . debug_enabled
50+ log_if_debug ( 'Starting Streaming mode ...' )
5151 start_push_status_monitor
5252 connected = @push_manager . start_sse
5353 end
5454
5555 unless connected
56- @config . logger . debug ( 'Starting Polling mode ...' ) if @config . debug_enabled
56+ log_if_debug ( 'Starting Polling mode ...' )
5757 @synchronizer . start_periodic_fetch
5858 record_telemetry ( Telemetry ::Domain ::Constants ::SYNC_MODE , SYNC_MODE_POLLING )
5959 end
@@ -92,7 +92,7 @@ def process_push_shutdown
9292
9393 def process_connected
9494 if @sse_connected . value
95- @config . logger . debug ( 'Streaming already connected.' ) if @config . debug_enabled
95+ log_if_debug ( 'Streaming already connected.' )
9696 return
9797 end
9898
@@ -107,7 +107,7 @@ def process_connected
107107
108108 def process_forced_stop
109109 unless @sse_connected . value
110- @config . logger . debug ( 'Streaming already disconnected.' ) if @config . debug_enabled
110+ log_if_debug ( 'Streaming already disconnected.' )
111111 return
112112 end
113113
@@ -120,7 +120,7 @@ def process_forced_stop
120120
121121 def process_disconnect ( reconnect )
122122 unless @sse_connected . value
123- @config . logger . debug ( 'Streaming already disconnected.' ) if @config . debug_enabled
123+ log_if_debug ( 'Streaming already disconnected.' )
124124 return
125125 end
126126
@@ -144,14 +144,14 @@ def record_telemetry(type, data)
144144
145145 def start_push_status_monitor
146146 @config . threads [ :push_status_handler ] = Thread . new do
147- @config . logger . debug ( 'Starting push status handler ...' ) if @config . debug_enabled
147+ log_if_debug ( 'Starting push status handler ...' )
148148 incoming_push_status_handler
149149 end
150150 end
151151
152152 def incoming_push_status_handler
153153 while ( status = @status_queue . pop )
154- @config . logger . debug ( "Push status handler dequeue #{ status } " ) if @config . debug_enabled
154+ log_if_debug ( "Push status handler dequeue #{ status } " )
155155
156156 case status
157157 when Constants ::PUSH_CONNECTED
@@ -169,12 +169,16 @@ def incoming_push_status_handler
169169 when Constants ::PUSH_SUBSYSTEM_OFF
170170 process_push_shutdown
171171 else
172- @config . logger . debug ( 'Incorrect push status type.' ) if @config . debug_enabled
172+ log_if_debug ( 'Incorrect push status type.' )
173173 end
174174 end
175175 rescue StandardError => e
176176 @config . logger . error ( "Push status handler error: #{ e . inspect } " )
177177 end
178178 end
179+
180+ def log_if_debug ( msg )
181+ @config . logger . debug ( msg ) if @config . debug_enabled
182+ end
179183 end
180184end
0 commit comments