coralogix_logger 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coralogix_logger.rb +7 -0
- data/lib/httpsender.rb +19 -18
- data/lib/manager.rb +14 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b33f65bf7b4312c21ed86d29ab6d65d316b1dfe7
|
4
|
+
data.tar.gz: 04e7b73f26794d0981530a21c53fd9f663032fe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11de4f0a3d676c8eb583029551e1a65b87db19271e3659cbf7b4c93c9789db25bf824b62fbed3aa882919c2666d8c1fa5cfbf25282dc9cc23ac59cc81725c39a
|
7
|
+
data.tar.gz: e5bd4b6430c257fda6fd88bf876bf98c7c6000a10ff46d8c2f4b2db934f7d3e4469df5c354579212af8a110cedcc79d9a9bb7d9edce6f3128608b1a9ef157b4c
|
data/lib/coralogix_logger.rb
CHANGED
@@ -104,6 +104,13 @@ module Coralogix
|
|
104
104
|
LoggerManager.reconnect
|
105
105
|
end
|
106
106
|
|
107
|
+
|
108
|
+
# Flush all messages in buffer and send them immediately on the current thread.
|
109
|
+
def flush
|
110
|
+
LoggerManager.flush
|
111
|
+
end
|
112
|
+
|
113
|
+
|
107
114
|
# Log a message.
|
108
115
|
#
|
109
116
|
# @param severity - log severity
|
data/lib/httpsender.rb
CHANGED
@@ -49,25 +49,26 @@ module Coralogix
|
|
49
49
|
#
|
50
50
|
# @param bulk - JSON bulk containing the log entries
|
51
51
|
def CoralogixHTTPSender.send_request bulk
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
52
|
+
@mutex.synchronize do
|
53
|
+
self.initialize unless @initialized
|
54
|
+
attempt = 0
|
55
|
+
while attempt < HTTP_SEND_RETRY_COUNT
|
56
|
+
begin
|
57
|
+
DebugLogger.info "About to send bulk to Coralogix server. Attempt number: #{attempt+1}"
|
58
|
+
@req.body = bulk.to_json
|
59
|
+
DebugLogger.debug Benchmark.measure {
|
60
|
+
res = @http.request(@req)
|
61
|
+
DebugLogger.info "Successfully sent bulk to Coralogix server. Result is: #{res.code}"
|
62
|
+
}.to_s
|
63
|
+
return true
|
64
|
+
rescue Exception => e
|
65
|
+
DebugLogger.error e.message
|
66
|
+
DebugLogger.error e.backtrace.inspect
|
67
|
+
end
|
68
|
+
attempt+=1;
|
69
|
+
DebugLogger.error "Failed to send bulk. Will retry in: #{HTTP_SEND_RETRY_INTERVAL} seconds..."
|
70
|
+
sleep HTTP_SEND_RETRY_INTERVAL
|
67
71
|
end
|
68
|
-
attempt+=1;
|
69
|
-
DebugLogger.error "Failed to send bulk. Will retry in: #{HTTP_SEND_RETRY_INTERVAL} seconds..."
|
70
|
-
sleep HTTP_SEND_RETRY_INTERVAL
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
data/lib/manager.rb
CHANGED
@@ -14,6 +14,8 @@ module Coralogix
|
|
14
14
|
|
15
15
|
def self.initialize
|
16
16
|
@bulk_template = {:privateKey => FAILED_PRIVATE_KEY, :applicationName => NO_APP_NAME, :subsystemName => NO_SUB_SYSTEM}
|
17
|
+
@time_delta_last_update = 0
|
18
|
+
@time_delta = 0
|
17
19
|
self.init
|
18
20
|
end
|
19
21
|
|
@@ -21,8 +23,7 @@ module Coralogix
|
|
21
23
|
@buffer = []
|
22
24
|
@buffer_size = 0
|
23
25
|
@mutex = Mutex.new
|
24
|
-
@
|
25
|
-
@time_delta = 0
|
26
|
+
@process= Process.pid
|
26
27
|
self.run
|
27
28
|
end
|
28
29
|
|
@@ -71,8 +72,9 @@ module Coralogix
|
|
71
72
|
# @return [boolean] return true for success or false for failure.
|
72
73
|
def self.add_logline message, severity, category, **args
|
73
74
|
begin
|
74
|
-
|
75
|
+
return if @mutex.nil?
|
75
76
|
@mutex.synchronize do
|
77
|
+
self.init if Process.pid != @process
|
76
78
|
if @buffer_size < MAX_LOG_BUFFER_SIZE
|
77
79
|
#Validate message
|
78
80
|
message = (message.nil? || message.to_s.strip.empty?) ? "EMPTY_STRING" : self.msg2str(message)
|
@@ -118,11 +120,16 @@ module Coralogix
|
|
118
120
|
return msg
|
119
121
|
end
|
120
122
|
end
|
123
|
+
|
124
|
+
# Flush all messages in buffer and send them immediately on the current thread.
|
125
|
+
def self.flush
|
126
|
+
self.send_bulk false
|
127
|
+
end
|
121
128
|
|
122
129
|
# Send bulk from the buffer
|
123
|
-
def self.send_bulk
|
130
|
+
def self.send_bulk time_sync=true
|
124
131
|
begin
|
125
|
-
self.update_time_delta_interval
|
132
|
+
self.update_time_delta_interval if time_sync
|
126
133
|
@mutex.synchronize do
|
127
134
|
# Total buffer size
|
128
135
|
size = @buffer.size
|
@@ -173,9 +180,9 @@ module Coralogix
|
|
173
180
|
end
|
174
181
|
end
|
175
182
|
|
176
|
-
# Spawn a new workter thread.
|
183
|
+
# Spawn a new workter thread. [Obsolete]
|
177
184
|
def self.reconnect
|
178
|
-
|
185
|
+
#Backword compatibilty
|
179
186
|
end
|
180
187
|
|
181
188
|
# Start timer execution.
|