centralized_ruby_logger 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/debug_logger.rb +2 -2
- data/lib/httpsender.rb +9 -9
- data/lib/manager.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ef705c6e4330c8a36cb16984aad708dad39b48a4a78b3c01cec87c5c99c498
|
4
|
+
data.tar.gz: f478764300a534ca8864702c256feecbc035bc4238edc6b6d9d623dfcf1753d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e386b8e11d8986d302d656dd2e7652ac754287d3be7b4dfbc927c862d8852d669fa23c0c661283bacd40a70e8378db1bf0f74f9d3f5096d80def7573faef756
|
7
|
+
data.tar.gz: 7fdc6c0d177fabda7dd0e0f91f32e49a9ce4e10d94c621e8c41e46a42c0ff44a9a7f595f9e503ebe9f8924b39232b7cb91a20832dcbe640f9ae7880effed6ef3
|
data/lib/debug_logger.rb
CHANGED
@@ -54,6 +54,7 @@ module Coralogix
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
Logger::Severity.const_set("TRACE", 0)
|
57
58
|
Logger::Severity.constants.each do |level|
|
58
59
|
define_singleton_method("#{level.downcase}") do |*args|
|
59
60
|
if @enabled
|
@@ -69,10 +70,9 @@ module Coralogix
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
end
|
73
|
+
end
|
73
74
|
end
|
74
75
|
|
75
|
-
|
76
76
|
initialize
|
77
77
|
|
78
78
|
end
|
data/lib/httpsender.rb
CHANGED
@@ -86,13 +86,13 @@ module Coralogix
|
|
86
86
|
attempt = 0
|
87
87
|
while attempt < HTTP_SEND_RETRY_COUNT
|
88
88
|
begin
|
89
|
-
DebugLogger.
|
89
|
+
DebugLogger.debug "About to send bulk to Coralogix server. Attempt number: #{attempt+1}"
|
90
90
|
|
91
|
-
DebugLogger.
|
91
|
+
DebugLogger.trace "Compressing bulk..."
|
92
92
|
zippedBulk = json2zip(bulk.to_json)
|
93
93
|
|
94
94
|
if zippedBulk.nil? && !@force_compression
|
95
|
-
DebugLogger.
|
95
|
+
DebugLogger.debug "Failed to compress bulk, sending raw data instead"
|
96
96
|
@req = Net::HTTP::Post.new(@uri.path, 'Content-Type' => 'application/json')
|
97
97
|
@req.body = bulk.to_json
|
98
98
|
else
|
@@ -101,13 +101,13 @@ module Coralogix
|
|
101
101
|
DebugLogger.error "Compressed bulk is nil"
|
102
102
|
end
|
103
103
|
|
104
|
-
DebugLogger.
|
104
|
+
DebugLogger.trace "Sending compressed bulk"
|
105
105
|
@req.body = zippedBulk
|
106
106
|
end
|
107
|
-
|
108
|
-
DebugLogger.
|
107
|
+
|
108
|
+
DebugLogger.trace Benchmark.measure {
|
109
109
|
res = @http.request(@req)
|
110
|
-
DebugLogger.
|
110
|
+
DebugLogger.debug "Successfully sent bulk to Coralogix server. Result is: #{res.code}"
|
111
111
|
}.to_s
|
112
112
|
return true
|
113
113
|
rescue Exception => e
|
@@ -127,7 +127,7 @@ module Coralogix
|
|
127
127
|
def get_time_sync
|
128
128
|
@mutex.synchronize do
|
129
129
|
begin
|
130
|
-
DebugLogger.
|
130
|
+
DebugLogger.trace "Syncing time with coralogix server"
|
131
131
|
res = @http.get(CORALOGIX_TIME_DELTA_URL)
|
132
132
|
|
133
133
|
if res.is_a?(Net::HTTPSuccess) && !res.body.to_s.empty?
|
@@ -140,7 +140,7 @@ module Coralogix
|
|
140
140
|
local_time = Time.now.utc
|
141
141
|
|
142
142
|
time_delta = (server_time - local_time) * 1000.0
|
143
|
-
DebugLogger.
|
143
|
+
DebugLogger.trace "Updating time delta to: #{time_delta}"
|
144
144
|
return true, time_delta
|
145
145
|
end
|
146
146
|
return false, 0
|
data/lib/manager.rb
CHANGED
@@ -32,7 +32,7 @@ module Coralogix
|
|
32
32
|
def configure args={}
|
33
33
|
begin
|
34
34
|
@bulk_template = args.merge({:computerName => `hostname`.strip})
|
35
|
-
DebugLogger.
|
35
|
+
DebugLogger.debug "Successfully configured Coralogix logger."
|
36
36
|
@configured = true
|
37
37
|
add_logline "The Application Name #{@bulk_template[:applicationName]} and Subsystem Name #{@bulk_template[:subsystemName]} from the #{@logger_type} SDK, version #{version?} has started to send data.", Severity::INFO, CORALOGIX_CATEGORY
|
38
38
|
rescue Exception => e
|
@@ -146,7 +146,7 @@ module Coralogix
|
|
146
146
|
# we need to take it anyway.
|
147
147
|
size = size > 0 ? size : 1
|
148
148
|
|
149
|
-
DebugLogger.
|
149
|
+
DebugLogger.debug "Checking buffer size. Total log entries is: #{size}"
|
150
150
|
@bulk_template[:logEntries] = @buffer.shift(size)
|
151
151
|
|
152
152
|
# Extract from the buffer size the total amount of the logs we removed from the buffer
|
@@ -155,7 +155,7 @@ module Coralogix
|
|
155
155
|
# Make sure we are always positive
|
156
156
|
@buffer_size = @buffer_size >= 0 ? @buffer_size : 0
|
157
157
|
|
158
|
-
DebugLogger.
|
158
|
+
DebugLogger.debug "Bufer size after removal is: #{@buffer.join(",").bytesize}"
|
159
159
|
end
|
160
160
|
@http_sender.send_request(@bulk_template) unless @bulk_template[:logEntries].empty?
|
161
161
|
rescue Exception => e
|
@@ -211,7 +211,7 @@ module Coralogix
|
|
211
211
|
# Check when is the next time we should send logs?
|
212
212
|
# If we already have at least half of the max chunk size then we are working in fast mode
|
213
213
|
next_check_interval = @buffer_size > (MAX_LOG_CHUNK_SIZE / 2) ? FAST_SEND_SPEED_INTERVAL : NORMAL_SEND_SPEED_INTERVAL
|
214
|
-
DebugLogger.
|
214
|
+
DebugLogger.trace "Next buffer check is scheduled in #{next_check_interval} seconds"
|
215
215
|
sleep next_check_interval
|
216
216
|
end
|
217
217
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: centralized_ruby_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Royee Goldberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Coralogix Centralized Ruby Logger to send logs to Coralogix server.
|
14
14
|
email: royee@coralogix.com
|