logster 2.9.0 → 2.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +63 -0
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +23 -0
- data/assets/javascript/client-app.js +65 -57
- data/client-app/app/controllers/index.js +12 -14
- data/client-app/app/lib/utilities.js +34 -0
- data/client-app/app/models/message-collection.js +13 -2
- data/client-app/app/routes/index.js +7 -1
- data/client-app/package-lock.json +25640 -219
- data/lib/logster/message.rb +3 -2
- data/lib/logster/middleware/debug_exceptions.rb +2 -4
- data/lib/logster/redis_store.rb +4 -1
- data/lib/logster/version.rb +1 -1
- data/logster.gemspec +1 -1
- data/test/logster/middleware/test_reporter.rb +3 -3
- data/test/logster/test_base_store.rb +12 -0
- data/test/logster/test_redis_store.rb +18 -0
- metadata +8 -8
- data/.travis.yml +0 -17
data/lib/logster/message.rb
CHANGED
@@ -99,7 +99,7 @@ module Logster
|
|
99
99
|
env["time"] = @timestamp || get_timestamp
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
self.env = Message.populate_from_env(env)
|
103
103
|
end
|
104
104
|
|
105
105
|
def self.default_env
|
@@ -113,7 +113,8 @@ module Logster
|
|
113
113
|
|
114
114
|
# in its own method so it can be overridden
|
115
115
|
def grouping_hash
|
116
|
-
|
116
|
+
message = self.message.gsub(/[0-9a-f]+/i, "X")
|
117
|
+
{ message: message, severity: self.severity, backtrace: self.backtrace }
|
117
118
|
end
|
118
119
|
|
119
120
|
# todo - memoize?
|
@@ -14,13 +14,11 @@ class Logster::Middleware::DebugExceptions < ActionDispatch::DebugExceptions
|
|
14
14
|
exception = wrapper.exception
|
15
15
|
|
16
16
|
Logster.config.current_context.call(env) do
|
17
|
-
location = exception.backtrace[0]
|
18
|
-
|
19
17
|
Logster.logger.add_with_opts(
|
20
18
|
::Logger::Severity::FATAL,
|
21
|
-
"#{exception.class} (#{exception})\n#{
|
19
|
+
"#{exception.class} (#{exception})\n#{wrapper.application_trace.join("\n")}",
|
22
20
|
"web-exception",
|
23
|
-
backtrace:
|
21
|
+
backtrace: wrapper.full_trace.join("\n"),
|
24
22
|
env: env
|
25
23
|
)
|
26
24
|
end
|
data/lib/logster/redis_store.rb
CHANGED
@@ -342,7 +342,10 @@ module Logster
|
|
342
342
|
def rate_limited?(ip_address, perform: false, limit: 60)
|
343
343
|
key = ip_rate_limit_key(ip_address)
|
344
344
|
|
345
|
-
limited = @redis.exists
|
345
|
+
limited = @redis.call([:exists, key])
|
346
|
+
if Integer === limited
|
347
|
+
limited = limited != 0
|
348
|
+
end
|
346
349
|
|
347
350
|
if perform && !limited
|
348
351
|
@redis.setex key, limit, ""
|
data/lib/logster/version.rb
CHANGED
data/logster.gemspec
CHANGED
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "guard-minitest"
|
34
34
|
spec.add_development_dependency "timecop"
|
35
35
|
spec.add_development_dependency "byebug", "~> 11.1.0"
|
36
|
-
spec.add_development_dependency "rubocop-discourse"
|
36
|
+
spec.add_development_dependency "rubocop-discourse"
|
37
37
|
end
|
@@ -28,19 +28,19 @@ class TestReporter < Minitest::Test
|
|
28
28
|
|
29
29
|
reporter = Logster::Middleware::Reporter.new(nil)
|
30
30
|
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello")
|
31
|
-
|
31
|
+
reporter.call(env)
|
32
32
|
|
33
33
|
assert_equal(Logger::Severity::WARN, Logster.store.latest[-1].severity)
|
34
34
|
|
35
35
|
reporter = Logster::Middleware::Reporter.new(nil)
|
36
36
|
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello&severity=invalid")
|
37
|
-
|
37
|
+
reporter.call(env)
|
38
38
|
|
39
39
|
assert_equal(Logger::Severity::WARN, Logster.store.latest[-1].severity)
|
40
40
|
|
41
41
|
reporter = Logster::Middleware::Reporter.new(nil)
|
42
42
|
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello&severity=error")
|
43
|
-
|
43
|
+
reporter.call(env)
|
44
44
|
|
45
45
|
assert_equal(Logger::Severity::ERROR, Logster.store.latest[-1].severity)
|
46
46
|
end
|
@@ -188,4 +188,16 @@ class TestBaseStore < Minitest::Test
|
|
188
188
|
refute_includes(store.reported.first.env.keys.map(&:to_sym), :backtrace)
|
189
189
|
end
|
190
190
|
end
|
191
|
+
|
192
|
+
def test_envs_with_invalid_encoding_dont_raise_errors
|
193
|
+
msg = @store.report(
|
194
|
+
Logger::WARN,
|
195
|
+
'',
|
196
|
+
'me have invalid encoding',
|
197
|
+
env: {
|
198
|
+
axe: "a\xF1xasa"
|
199
|
+
}
|
200
|
+
)
|
201
|
+
assert_equal("a�xasa", msg.env[:axe])
|
202
|
+
end
|
191
203
|
end
|
@@ -1044,6 +1044,24 @@ class TestRedisStore < Minitest::Test
|
|
1044
1044
|
end
|
1045
1045
|
end
|
1046
1046
|
|
1047
|
+
def test_messages_that_differ_only_by_numbers_or_hashes_are_merged
|
1048
|
+
config_reset(allow_grouping: true) do
|
1049
|
+
first_message = <<~TEXT
|
1050
|
+
DistributedMutex("download_20450e291e8f1e5ba03ca7f20fb7d9da570c94a6"):
|
1051
|
+
held for too long, expected max: 60 secs, took an extra 73 secs
|
1052
|
+
TEXT
|
1053
|
+
msg = @store.report(Logger::WARN, '', first_message, backtrace: caller)
|
1054
|
+
|
1055
|
+
second_message = <<~TEXT
|
1056
|
+
DistributedMutex("download_e09ae082c60a351dedec67ed869652862b232a0b"):
|
1057
|
+
held for too long, expected max: 60 secs, took an extra 287 secs
|
1058
|
+
TEXT
|
1059
|
+
msg2 = @store.report(Logger::WARN, '', second_message, backtrace: caller)
|
1060
|
+
|
1061
|
+
assert_equal(msg.key, msg2.key)
|
1062
|
+
end
|
1063
|
+
end
|
1064
|
+
|
1047
1065
|
private
|
1048
1066
|
|
1049
1067
|
def config_reset(configs)
|
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.9.
|
4
|
+
version: 2.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -126,16 +126,16 @@ dependencies:
|
|
126
126
|
name: rubocop-discourse
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: '0'
|
139
139
|
description: UI for viewing logs in Rack
|
140
140
|
email:
|
141
141
|
- sam.saffron@gmail.com
|
@@ -143,9 +143,9 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
+
- ".github/workflows/ci.yml"
|
146
147
|
- ".gitignore"
|
147
148
|
- ".rubocop.yml"
|
148
|
-
- ".travis.yml"
|
149
149
|
- CHANGELOG.md
|
150
150
|
- Gemfile
|
151
151
|
- Guardfile
|
@@ -295,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
295
295
|
- !ruby/object:Gem::Version
|
296
296
|
version: '0'
|
297
297
|
requirements: []
|
298
|
-
rubygems_version: 3.
|
298
|
+
rubygems_version: 3.0.3
|
299
299
|
signing_key:
|
300
300
|
specification_version: 4
|
301
301
|
summary: UI for viewing logs in Rack
|