logster 2.6.3 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -1
- data/lib/logster/base_store.rb +7 -0
- data/lib/logster/configuration.rb +3 -1
- data/lib/logster/message.rb +1 -13
- data/lib/logster/version.rb +1 -1
- data/test/logster/test_base_store.rb +14 -0
- data/test/logster/test_message.rb +0 -6
- 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: 106a0763acb86a917c9a1b2f3a3e80cfc4e9ef789a1904e76499d62ff5f66298
|
4
|
+
data.tar.gz: 74aef16f2994ddde18124e9a914decb094fa275813eb31d396190f4bbd4d4e35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecc9724cc453bbf7c909c7ab9f6857250afc246dd1bc535ad7d29bbb1df7917c8f64b7e64f5a78d686f7118386c4359791fde6d8ca9e945e5f8213e3d76d8466
|
7
|
+
data.tar.gz: ae722de77352b4c355ae7f330d3af1697142394ea63f5a5a67dcfaeb1e6fe9594278e4a0deb2f647a0ba6a89f4297ed16592d421b1b98709991e95160a427f8a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -48,7 +48,9 @@ Logster can be configured using `Logster.config`:
|
|
48
48
|
|
49
49
|
- `Logster.config.allow_grouping` : Enable grouping of similar messages into one messages with an array of `env` of the grouped messages. Similar messages are messages that have identical backtraces, severity and log message.
|
50
50
|
|
51
|
-
- `Logster.config.
|
51
|
+
- `Logster.config.maximum_message_length` : set a maximum length for log messages that are shown inside the `info` tab and in the message rows in the UI. Messages that exceed the specified length will be truncated and an ellipsis will be appended to indicate that the message has been truncated. Default value is 2000.
|
52
|
+
|
53
|
+
- `Logster.config.maximum_message_size_bytes` : set a maximum size for message objects. Default value is 10,000. If a message size exceeds this limit, Logster will first remove all occurrences of `gems_dir` (more on this config below) from the backtrace and computes the size again; if the message is still above the limit, Logster will remove as many as character as needed from the backtrace to bring the size below the limit. It's discouraged to set this config to a really low value (e.g. less than 2000) because a message needs a minimum amount of data in order to make sense (the minimum amount varies per message), so the closer the limit is to the mimimum amount of space needed, the more of the backtrace will be removed. Keep this in mind when tweaking this config.
|
52
54
|
|
53
55
|
- `Logster.config.max_env_bytes` : set a maximum size for `env`. Default value is 1000. In case `env` is an array of hashes, this limit applies to the individual hashes in the array rather than the whole array. If an `env` hash exceeds this limit, Logster will take the biggest subset of key-value pairs whose size is below the limit. If the hash has a key with the name `time`, it will always be included.
|
54
56
|
|
data/lib/logster/base_store.rb
CHANGED
@@ -152,6 +152,8 @@ module Logster
|
|
152
152
|
return if (!msg || (String === msg && msg.empty?)) && skip_empty
|
153
153
|
return if level && severity < level
|
154
154
|
|
155
|
+
msg = msg.inspect unless String === msg
|
156
|
+
msg = truncate_message(msg)
|
155
157
|
message = Logster::Message.new(severity, progname, msg, opts[:timestamp], count: opts[:count])
|
156
158
|
|
157
159
|
env = opts[:env] || {}
|
@@ -245,6 +247,11 @@ module Logster
|
|
245
247
|
|
246
248
|
private
|
247
249
|
|
250
|
+
def truncate_message(msg)
|
251
|
+
cap = Logster.config.maximum_message_length
|
252
|
+
msg.size <= cap ? msg : msg[0...cap] + "..."
|
253
|
+
end
|
254
|
+
|
248
255
|
def not_implemented
|
249
256
|
raise "Not Implemented"
|
250
257
|
end
|
@@ -17,7 +17,8 @@ module Logster
|
|
17
17
|
:enable_backtrace_links,
|
18
18
|
:gems_dir,
|
19
19
|
:max_env_bytes,
|
20
|
-
:max_env_count_per_message
|
20
|
+
:max_env_count_per_message,
|
21
|
+
:maximum_message_length
|
21
22
|
)
|
22
23
|
|
23
24
|
attr_writer :subdirectory
|
@@ -37,6 +38,7 @@ module Logster
|
|
37
38
|
@project_directories = []
|
38
39
|
@enable_backtrace_links = true
|
39
40
|
@gems_dir = Gem.dir + "/gems/"
|
41
|
+
@maximum_message_length = 2000
|
40
42
|
|
41
43
|
@allow_grouping = false
|
42
44
|
|
data/lib/logster/message.rb
CHANGED
@@ -4,8 +4,6 @@ require 'digest/sha1'
|
|
4
4
|
require 'securerandom'
|
5
5
|
|
6
6
|
module Logster
|
7
|
-
MAX_MESSAGE_LENGTH = 600
|
8
|
-
|
9
7
|
class Message
|
10
8
|
LOGSTER_ENV = "_logster_env".freeze
|
11
9
|
ALLOWED_ENV = %w{
|
@@ -30,7 +28,7 @@ module Logster
|
|
30
28
|
@timestamp = timestamp || get_timestamp
|
31
29
|
@severity = severity
|
32
30
|
@progname = progname
|
33
|
-
@message =
|
31
|
+
@message = message
|
34
32
|
@key = key || SecureRandom.hex
|
35
33
|
@backtrace = nil
|
36
34
|
@count = count || 1
|
@@ -57,10 +55,6 @@ module Logster
|
|
57
55
|
h
|
58
56
|
end
|
59
57
|
|
60
|
-
def message=(m)
|
61
|
-
@message = truncate_message(m)
|
62
|
-
end
|
63
|
-
|
64
58
|
def to_json(opts = nil)
|
65
59
|
exclude_env = Hash === opts && opts.delete(:exclude_env)
|
66
60
|
JSON.fast_generate(to_h(exclude_env: exclude_env), opts)
|
@@ -311,12 +305,6 @@ module Logster
|
|
311
305
|
end
|
312
306
|
end
|
313
307
|
|
314
|
-
def truncate_message(msg)
|
315
|
-
return msg unless msg
|
316
|
-
msg = msg.inspect unless String === msg
|
317
|
-
msg.size <= MAX_MESSAGE_LENGTH ? msg : msg[0...MAX_MESSAGE_LENGTH] + "..."
|
318
|
-
end
|
319
|
-
|
320
308
|
def get_timestamp
|
321
309
|
(Time.new.to_f * 1000).to_i
|
322
310
|
end
|
data/lib/logster/version.rb
CHANGED
@@ -162,4 +162,18 @@ class TestBaseStore < Minitest::Test
|
|
162
162
|
assert_includes(message.backtrace.lines.first, __method__.to_s)
|
163
163
|
end
|
164
164
|
end
|
165
|
+
|
166
|
+
def test_log_message_is_truncated_when_above_maximum_message_length
|
167
|
+
orig = Logster.config.maximum_message_length
|
168
|
+
Logster.config.maximum_message_length = 300
|
169
|
+
msg = @store.report(Logger::WARN, '', 'a' * 400)
|
170
|
+
# 3 is the ... at the end to indicate truncated message
|
171
|
+
assert_equal(300 + 3, msg.message.size)
|
172
|
+
|
173
|
+
Logster.config.maximum_message_length = 100
|
174
|
+
msg = @store.report(Logger::WARN, '', 'a' * 200)
|
175
|
+
assert_equal(100 + 3, msg.message.size)
|
176
|
+
ensure
|
177
|
+
Logster.config.maximum_message_length = orig
|
178
|
+
end
|
165
179
|
end
|
@@ -146,12 +146,6 @@ class TestMessage < MiniTest::Test
|
|
146
146
|
refute_includes(msg.to_json(exclude_env: true), test_hash.to_json)
|
147
147
|
end
|
148
148
|
|
149
|
-
def test_title_is_truncated_when_too_large
|
150
|
-
msg = Logster::Message.new(0, "", "a" * 1000)
|
151
|
-
# 3 is the ... at the end to indicate truncated message
|
152
|
-
assert_equal(600 + 3, msg.message.size)
|
153
|
-
end
|
154
|
-
|
155
149
|
def test_drop_redundant_envs
|
156
150
|
message = Logster::Message.new(Logger::WARN, '', 'message')
|
157
151
|
message.env = [{ a: 4 }] * 10
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- UI for viewing logs in Rack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|