@@ -38,23 +38,23 @@ def initialize(config,
3838
3939 def close ( status = nil )
4040 unless connected?
41- @config . logger . debug ( 'SSEClient already disconected.' )
41+ @config . logger . debug ( 'SSEClient already disconected.' ) if @config . debug_enabled
4242 return
4343 end
44- @config . logger . debug ( "Closing SSEClient socket" )
44+ @config . logger . debug ( "Closing SSEClient socket" ) if @config . debug_enabled
4545
4646 push_status ( status )
4747 @connected . make_false
4848 @socket . sync_close = true if @socket . is_a? OpenSSL ::SSL ::SSLSocket
4949 @socket . close
50- @config . logger . debug ( "SSEClient socket state #{ @socket . state } " ) if @socket . is_a? OpenSSL ::SSL ::SSLSocket
50+ @config . logger . debug ( "SSEClient socket state #{ @socket . state } " ) if @socket . is_a? OpenSSL ::SSL ::SSLSocket && @config . debug_enabled
5151 rescue StandardError => e
5252 @config . logger . error ( "SSEClient close Error: #{ e . inspect } " )
5353 end
5454
5555 def start ( url )
5656 if connected?
57- @config . logger . debug ( 'SSEClient already running.' )
57+ @config . logger . debug ( 'SSEClient already running.' ) if @config . debug_enabled
5858 return true
5959 end
6060
@@ -96,18 +96,17 @@ def connect_stream(latch)
9696
9797 raise 'eof exception' if partial_data == :eof
9898 rescue IO ::WaitReadable => e
99- @config . logger . debug ( "SSE client IO::WaitReadable transient error: #{ e . inspect } " )
99+ @config . logger . debug ( "SSE client IO::WaitReadable transient error: #{ e . inspect } " ) if @config . debug_enabled
100100 IO . select ( [ @socket ] , nil , nil , @read_timeout )
101101 retry
102102 rescue Errno ::EAGAIN => e
103- @config . logger . debug ( "SSE client transient error: #{ e . inspect } " )
103+ @config . logger . debug ( "SSE client transient error: #{ e . inspect } " ) if @config . debug_enabled
104104 IO . select ( [ @socket ] , nil , nil , @read_timeout )
105105 retry
106106 rescue Errno ::ETIMEDOUT => e
107107 @config . logger . error ( "SSE read operation timed out!: #{ e . inspect } " )
108108 return Constants ::PUSH_RETRYABLE_ERROR
109109 rescue EOFError => e
110- puts "SSE read operation EOF Exception!: #{ e . inspect } "
111110 @config . logger . error ( "SSE read operation EOF Exception!: #{ e . inspect } " )
112111 raise 'eof exception'
113112 rescue Errno ::EBADF , IOError => e
@@ -125,12 +124,12 @@ def connect_stream(latch)
125124 return Constants ::PUSH_RETRYABLE_ERROR
126125 end
127126 rescue Errno ::EBADF
128- @config . logger . debug ( "SSE socket is not connected (Errno::EBADF)" )
127+ @config . logger . debug ( "SSE socket is not connected (Errno::EBADF)" ) if @config . debug_enabled
129128 break
130129 rescue RuntimeError
131130 raise 'eof exception'
132131 rescue Exception => e
133- @config . logger . debug ( "SSE socket is not connected: #{ e . inspect } " )
132+ @config . logger . debug ( "SSE socket is not connected: #{ e . inspect } " ) if @config . debug_enabled
134133 break
135134 end
136135
@@ -156,7 +155,7 @@ def read_first_event(data, latch)
156155 return unless @first_event . value
157156
158157 response_code = @event_parser . first_event ( data )
159- @config . logger . debug ( "SSE client first event code: #{ response_code } " )
158+ @config . logger . debug ( "SSE client first event code: #{ response_code } " ) if @config . debug_enabled
160159
161160 error_event = false
162161 events = @event_parser . parse ( data )
@@ -165,7 +164,7 @@ def read_first_event(data, latch)
165164
166165 if response_code == OK_CODE && !error_event
167166 @connected . make_true
168- @config . logger . debug ( "SSE client first event Connected is true" )
167+ @config . logger . debug ( "SSE client first event Connected is true" ) if @config . debug_enabled
169168 @telemetry_runtime_producer . record_streaming_event ( Telemetry ::Domain ::Constants ::SSE_CONNECTION_ESTABLISHED , nil )
170169 push_status ( Constants ::PUSH_CONNECTED )
171170 end
@@ -202,7 +201,7 @@ def socket_connect
202201 end
203202
204203 def process_data ( partial_data )
205- @config . logger . debug ( "Event partial data: #{ partial_data } " )
204+ @config . logger . debug ( "Event partial data: #{ partial_data } " ) if @config . debug_enabled
206205 return if partial_data . nil? || partial_data == KEEP_ALIVE_RESPONSE
207206
208207 events = @event_parser . parse ( partial_data )
@@ -220,7 +219,7 @@ def build_request(uri)
220219 req << "SplitSDKMachineName: #{ @config . machine_name } \r \n "
221220 req << "SplitSDKClientKey: #{ @api_key . split ( // ) . last ( 4 ) . join } \r \n " unless @api_key . nil?
222221 req << "Cache-Control: no-cache\r \n \r \n "
223- @config . logger . debug ( "Request info: #{ req } " )
222+ @config . logger . debug ( "Request info: #{ req } " ) if @config . debug_enabled
224223 req
225224 end
226225
@@ -255,7 +254,7 @@ def dispatch_event(event)
255254 def push_status ( status )
256255 return if status . nil?
257256
258- @config . logger . debug ( "Pushing new sse status: #{ status } " )
257+ @config . logger . debug ( "Pushing new sse status: #{ status } " ) if @config . debug_enabled
259258 @status_queue . push ( status )
260259 end
261260 end
0 commit comments