logjam_agent 0.26.4 → 0.26.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/logjam_agent/request.rb +15 -9
- data/lib/logjam_agent/version.rb +1 -1
- data/test/request_test.rb +46 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e5baacba1e04a269ab06f2c2b64f415da9fe20b5605131c72b14f4da7f6222c
|
4
|
+
data.tar.gz: ab45f9c10b79b8f22d16c4fc9a63e6adf0ad389b85664024ddff8696f56dc2b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 180596a41cdf18f05d7032bf6e2da5f4140ad5f5da22a62392aced9e169af4f237393bd68be274a2224e57dd05557908d2c50d0f081340c2bda951888041d52a
|
7
|
+
data.tar.gz: 5697f97094cc3ae57f84ff5537d1e0665ac8f2b72437111615273f1b94d61a790d3fe220d9e9854de691bf386f877d83c53e9b04dcba84233bfe59dbcdb4983c
|
data/lib/logjam_agent/request.rb
CHANGED
@@ -37,6 +37,7 @@ module LogjamAgent
|
|
37
37
|
@bytes_all_lines = 0
|
38
38
|
@max_bytes_all_lines = LogjamAgent.max_bytes_all_lines
|
39
39
|
@max_line_length = LogjamAgent.max_line_length
|
40
|
+
@lines_dropped = false
|
40
41
|
end
|
41
42
|
|
42
43
|
def start_time=(start_time)
|
@@ -70,17 +71,22 @@ module LogjamAgent
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def add_line(severity, timestamp, message)
|
73
|
-
return if @bytes_all_lines > @max_bytes_all_lines
|
74
|
-
message = message.strip
|
75
|
-
if message.size > @max_line_length && severity < Logger::ERROR
|
76
|
-
message[(@max_line_length-21)..-1] = " ... [LINE TRUNCATED]"
|
77
|
-
end
|
78
74
|
@mutex.synchronize do
|
79
|
-
if
|
80
|
-
@
|
81
|
-
|
82
|
-
|
75
|
+
if @bytes_all_lines > @max_bytes_all_lines
|
76
|
+
unless @lines_dropped
|
77
|
+
@lines << [severity, format_time(timestamp), "... [LINES DROPPED]"]
|
78
|
+
@lines_dropped = true
|
79
|
+
end
|
80
|
+
return
|
81
|
+
end
|
82
|
+
message = message.strip
|
83
|
+
if message.size > @max_line_length && severity < Logger::ERROR
|
84
|
+
message[(@max_line_length-21)..-1] = " ... [LINE TRUNCATED]"
|
85
|
+
end
|
86
|
+
if (@bytes_all_lines += message.bytesize) > @max_bytes_all_lines
|
87
|
+
message[(@max_line_length-21)..-1] = " ... [LINE TRUNCATED]"
|
83
88
|
end
|
89
|
+
@lines << [severity, format_time(timestamp), message]
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
data/lib/logjam_agent/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative "test_helper.rb"
|
2
|
+
|
3
|
+
module LogjamAgent
|
4
|
+
class RequestTest < MiniTest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@request = Request.new("app", "env", {})
|
8
|
+
@request.instance_eval do
|
9
|
+
@max_bytes_all_lines = 100
|
10
|
+
@max_line_length = 50
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
TRUNCATED_LINE = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx ... [LINE TRUNCATED]"
|
15
|
+
|
16
|
+
def test_truncates_lines_longer_than_max_line_length
|
17
|
+
@request.add_line(Logger::INFO, Time.now, "x" * 51)
|
18
|
+
assert_equal 1, lines(@request).size
|
19
|
+
assert_equal TRUNCATED_LINE, lines(@request).first[2]
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_truncates_messages_larger_than_max_bytes_all_lines
|
23
|
+
@request.add_line(Logger::INFO, Time.now, "x" * 150)
|
24
|
+
assert_equal 1, lines(@request).size
|
25
|
+
assert_equal TRUNCATED_LINE, lines(@request).first[2]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_does_not_truncate_error_lines_if_overall_message_size_is_still_ok
|
29
|
+
@request.add_line(Logger::ERROR, Time.now, "x" * 70)
|
30
|
+
assert_equal 1, lines(@request).size
|
31
|
+
assert_equal "x" * 70, lines(@request).first[2]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_truncates_error_lines_if_message_size_id_larger_than_max_bytes_all_lines
|
35
|
+
@request.add_line(Logger::ERROR, Time.now, "x" * 120)
|
36
|
+
assert_equal 1, lines(@request).size
|
37
|
+
assert_equal TRUNCATED_LINE, lines(@request).first[2]
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def lines(request)
|
43
|
+
request.instance_variable_get :@lines
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjam_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.26.
|
4
|
+
version: 0.26.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- logjam_agent.gemspec
|
164
164
|
- script/console
|
165
165
|
- test/amqp_forwarder_test.rb
|
166
|
+
- test/request_test.rb
|
166
167
|
- test/test_helper.rb
|
167
168
|
- test/util_test.rb
|
168
169
|
- test/zmq_forwarder_test.rb
|
@@ -185,12 +186,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
186
|
version: '0'
|
186
187
|
requirements: []
|
187
188
|
rubyforge_project: logjam_agent
|
188
|
-
rubygems_version: 2.6
|
189
|
+
rubygems_version: 2.7.6
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: Logjam client library to be used with logjam
|
192
193
|
test_files:
|
193
194
|
- test/amqp_forwarder_test.rb
|
195
|
+
- test/request_test.rb
|
194
196
|
- test/test_helper.rb
|
195
197
|
- test/util_test.rb
|
196
198
|
- test/zmq_forwarder_test.rb
|