logster 2.8.0 → 2.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +0 -1
- data/CHANGELOG.md +25 -0
- data/README.md +2 -2
- data/assets/javascript/client-app.js +170 -131
- data/assets/javascript/vendor.js +151 -128
- data/build_client_app.sh +1 -1
- data/client-app/.eslintignore +0 -2
- data/client-app/.gitignore +0 -2
- data/client-app/app/controllers/index.js +17 -14
- data/client-app/app/lib/utilities.js +37 -1
- 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 +1241 -220
- data/client-app/package.json +5 -5
- data/client-app/tests/integration/components/env-tab-test.js +2 -2
- data/lib/logster/message.rb +3 -6
- data/lib/logster/middleware/debug_exceptions.rb +2 -4
- data/lib/logster/middleware/reporter.rb +8 -1
- data/lib/logster/middleware/viewer.rb +8 -8
- data/lib/logster/redis_store.rb +4 -1
- data/lib/logster/version.rb +1 -1
- data/logster.gemspec +4 -5
- data/test/logster/middleware/test_reporter.rb +23 -0
- data/test/logster/test_group.rb +1 -1
- data/test/logster/test_message.rb +1 -1
- data/test/logster/test_redis_store.rb +18 -0
- metadata +8 -22
data/client-app/package.json
CHANGED
@@ -24,18 +24,18 @@
|
|
24
24
|
"@fortawesome/free-regular-svg-icons": "^5.13.0",
|
25
25
|
"@fortawesome/free-solid-svg-icons": "^5.13.0",
|
26
26
|
"@glimmer/component": "^1.0.0",
|
27
|
-
"babel-eslint": "^10.0
|
27
|
+
"babel-eslint": "^10.1.0",
|
28
28
|
"broccoli-asset-rev": "^3.0.0",
|
29
29
|
"ember-auto-import": "^1.5.3",
|
30
30
|
"ember-cli": "^3.15.0",
|
31
31
|
"ember-cli-app-version": "^3.2.0",
|
32
|
-
"ember-cli-babel": "^7.
|
32
|
+
"ember-cli-babel": "^7.19.0",
|
33
33
|
"ember-cli-dependency-checker": "^3.2.0",
|
34
34
|
"ember-cli-eslint": "^5.1.0",
|
35
|
-
"ember-cli-htmlbars": "^4.
|
35
|
+
"ember-cli-htmlbars": "^4.3.1",
|
36
36
|
"ember-cli-inject-live-reload": "^2.0.1",
|
37
37
|
"ember-cli-sri": "^2.1.1",
|
38
|
-
"ember-cli-template-lint": "^1.0.0
|
38
|
+
"ember-cli-template-lint": "^1.0.0",
|
39
39
|
"ember-cli-uglify": "^3.0.0",
|
40
40
|
"ember-export-application-global": "^2.0.1",
|
41
41
|
"ember-load-initializers": "^2.1.1",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"ember-qunit": "^4.6.0",
|
44
44
|
"ember-resolver": "^7.0.0",
|
45
45
|
"ember-source": "^3.15.0",
|
46
|
-
"eslint-plugin-ember": "^7.
|
46
|
+
"eslint-plugin-ember": "^7.13.0",
|
47
47
|
"eslint-plugin-node": "^10.0.0",
|
48
48
|
"loader.js": "^4.7.0",
|
49
49
|
"prettier": "^1.19.1",
|
@@ -148,7 +148,7 @@ module("Integration | Component | env-tab", function(hooks) {
|
|
148
148
|
|
149
149
|
assert.equal(
|
150
150
|
defaultExpanded.children[1].textContent.trim(),
|
151
|
-
"
|
151
|
+
"vvv1, [vvv2]",
|
152
152
|
"list is expanded by default when its length is 3 or less"
|
153
153
|
);
|
154
154
|
|
@@ -165,7 +165,7 @@ module("Integration | Component | env-tab", function(hooks) {
|
|
165
165
|
const expanded = find(".env-table tr");
|
166
166
|
assert.equal(
|
167
167
|
expanded.children[1].textContent.trim(),
|
168
|
-
"
|
168
|
+
"value1, [value2, value3, value4]",
|
169
169
|
"expanded env keys shown correctly"
|
170
170
|
);
|
171
171
|
|
data/lib/logster/message.rb
CHANGED
@@ -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?
|
@@ -137,10 +138,6 @@ module Logster
|
|
137
138
|
end
|
138
139
|
end
|
139
140
|
|
140
|
-
def is_similar?(other)
|
141
|
-
self.grouping_key == other.grouping_key
|
142
|
-
end
|
143
|
-
|
144
141
|
def merge_similar_message(other)
|
145
142
|
self.first_timestamp ||= self.timestamp
|
146
143
|
self.timestamp = [self.timestamp, other.timestamp].max
|
@@ -306,7 +303,7 @@ module Logster
|
|
306
303
|
end
|
307
304
|
|
308
305
|
def get_timestamp
|
309
|
-
(Time.
|
306
|
+
(Time.now.to_f * 1000).to_i
|
310
307
|
end
|
311
308
|
end
|
312
309
|
end
|
@@ -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
|
@@ -57,7 +57,14 @@ module Logster
|
|
57
57
|
message << "\nWindow Location: " << params["window_location"] if params["window_location"]
|
58
58
|
|
59
59
|
backtrace = params["stacktrace"] || ""
|
60
|
-
|
60
|
+
|
61
|
+
severity = ::Logger::Severity::WARN
|
62
|
+
if params["severity"] &&
|
63
|
+
::Logger::Severity.const_defined?(params["severity"].upcase)
|
64
|
+
severity = ::Logger::Severity.const_get(params["severity"].upcase)
|
65
|
+
end
|
66
|
+
|
67
|
+
Logster.store.report(severity,
|
61
68
|
"javascript",
|
62
69
|
message,
|
63
70
|
backtrace: backtrace,
|
@@ -48,7 +48,7 @@ module Logster
|
|
48
48
|
end
|
49
49
|
|
50
50
|
Logster.store.delete(message)
|
51
|
-
|
51
|
+
[301, { "Location" => "#{@logs_path}/" }, []]
|
52
52
|
|
53
53
|
elsif resource =~ /\/(un)?protect\/([0-9a-f]+)$/
|
54
54
|
off = $1 == "un"
|
@@ -61,15 +61,15 @@ module Logster
|
|
61
61
|
|
62
62
|
if off
|
63
63
|
if Logster.store.unprotect(key)
|
64
|
-
|
64
|
+
[301, { "Location" => "#{@logs_path}/show/#{key}?protected=false" }, []]
|
65
65
|
else
|
66
|
-
|
66
|
+
[500, {}, ["Failed"]]
|
67
67
|
end
|
68
68
|
else
|
69
69
|
if Logster.store.protect(key)
|
70
|
-
|
70
|
+
[301, { "Location" => "#{@logs_path}/show/#{key}?protected=true" }, []]
|
71
71
|
else
|
72
|
-
|
72
|
+
[500, {}, ["Failed"]]
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -83,14 +83,14 @@ module Logster
|
|
83
83
|
|
84
84
|
Logster.store.solve(key)
|
85
85
|
|
86
|
-
|
86
|
+
[301, { "Location" => "#{@logs_path}" }, []]
|
87
87
|
|
88
88
|
elsif resource =~ /\/clear$/
|
89
89
|
if env[REQUEST_METHOD] != "POST"
|
90
90
|
return method_not_allowed("POST")
|
91
91
|
end
|
92
92
|
Logster.store.clear
|
93
|
-
|
93
|
+
[200, {}, ["Messages cleared"]]
|
94
94
|
|
95
95
|
elsif resource =~ /\/show\/([0-9a-f]+)(\.json)?$/
|
96
96
|
key = $1
|
@@ -179,7 +179,7 @@ module Logster
|
|
179
179
|
end.first
|
180
180
|
return not_found("No such pattern group exists") if !group
|
181
181
|
group.messages_keys.each { |k| Logster.store.solve(k) }
|
182
|
-
|
182
|
+
[200, {}, []]
|
183
183
|
elsif resource == '/development-preload.json' && ENV["LOGSTER_ENV"] == "development"
|
184
184
|
[200, { "Content-Type" => "application/json; charset=utf-8" }, [JSON.generate(preloaded_data)]]
|
185
185
|
else
|
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
@@ -8,7 +8,7 @@ require 'logster/version'
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.name = "logster"
|
10
10
|
spec.version = Logster::VERSION
|
11
|
-
spec.authors = ["
|
11
|
+
spec.authors = ["Sam Saffron"]
|
12
12
|
spec.email = ["sam.saffron@gmail.com"]
|
13
13
|
spec.summary = %q{UI for viewing logs in Rack}
|
14
14
|
spec.description = %q{UI for viewing logs in Rack}
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
-
f.start_with?("
|
19
|
+
f.start_with?("website") || f.start_with?("bin")
|
20
20
|
end
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency "guard"
|
33
33
|
spec.add_development_dependency "guard-minitest"
|
34
34
|
spec.add_development_dependency "timecop"
|
35
|
-
spec.add_development_dependency "byebug", "~> 11.
|
36
|
-
spec.add_development_dependency "rubocop", "~>
|
37
|
-
spec.add_development_dependency "rubocop-discourse"
|
35
|
+
spec.add_development_dependency "byebug", "~> 11.1.0"
|
36
|
+
spec.add_development_dependency "rubocop-discourse", "~> 2.1.2"
|
38
37
|
end
|
@@ -11,6 +11,7 @@ class TestReporter < Minitest::Test
|
|
11
11
|
Logster.store = Logster::RedisStore.new
|
12
12
|
Logster.store.clear_all
|
13
13
|
Logster.config.enable_js_error_reporting = true
|
14
|
+
Logster.config.rate_limit_error_reporting = true
|
14
15
|
end
|
15
16
|
|
16
17
|
def test_logs_errors
|
@@ -22,6 +23,28 @@ class TestReporter < Minitest::Test
|
|
22
23
|
assert_equal(1, Logster.store.count)
|
23
24
|
end
|
24
25
|
|
26
|
+
def test_logs_severity_of_errors
|
27
|
+
Logster.config.rate_limit_error_reporting = false
|
28
|
+
|
29
|
+
reporter = Logster::Middleware::Reporter.new(nil)
|
30
|
+
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello")
|
31
|
+
reporter.call(env)
|
32
|
+
|
33
|
+
assert_equal(Logger::Severity::WARN, Logster.store.latest[-1].severity)
|
34
|
+
|
35
|
+
reporter = Logster::Middleware::Reporter.new(nil)
|
36
|
+
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello&severity=invalid")
|
37
|
+
reporter.call(env)
|
38
|
+
|
39
|
+
assert_equal(Logger::Severity::WARN, Logster.store.latest[-1].severity)
|
40
|
+
|
41
|
+
reporter = Logster::Middleware::Reporter.new(nil)
|
42
|
+
env = Rack::MockRequest.env_for("/logs/report_js_error?message=hello&severity=error")
|
43
|
+
reporter.call(env)
|
44
|
+
|
45
|
+
assert_equal(Logger::Severity::ERROR, Logster.store.latest[-1].severity)
|
46
|
+
end
|
47
|
+
|
25
48
|
def test_respects_ban_on_errors
|
26
49
|
Logster.config.enable_js_error_reporting = false
|
27
50
|
|
data/test/logster/test_group.rb
CHANGED
@@ -10,7 +10,7 @@ class TestGroup < MiniTest::Test
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_from_json_works_correctly
|
13
|
-
time = (Time.
|
13
|
+
time = (Time.now.to_f * 1000).to_i - 5000
|
14
14
|
json = JSON.generate(
|
15
15
|
key: '/somekey/',
|
16
16
|
messages_keys: [111, 222, 333].map(&:to_s),
|
@@ -20,7 +20,7 @@ class TestMessage < MiniTest::Test
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_populate_from_env_will_add_time_to_env_unless_it_already_exists
|
23
|
-
t = (Time.
|
23
|
+
t = (Time.now.to_f * 1000).to_i
|
24
24
|
msg = Logster::Message.new(0, '', 'test', t)
|
25
25
|
msg.populate_from_env({})
|
26
26
|
assert_equal(t, msg.env["time"])
|
@@ -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.
|
4
|
+
version: 2.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,42 +114,28 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 11.
|
117
|
+
version: 11.1.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 11.
|
124
|
+
version: 11.1.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop
|
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: 2.1.2
|
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:
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rubocop-discourse
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
138
|
+
version: 2.1.2
|
153
139
|
description: UI for viewing logs in Rack
|
154
140
|
email:
|
155
141
|
- sam.saffron@gmail.com
|