logster 2.12.1 → 2.13.0
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 +5 -0
- data/.streerc +2 -0
- data/CHANGELOG.md +10 -1
- data/Gemfile +1 -1
- data/assets/javascript/{chunk.143.2faa04830259ce9aa59a.js → chunk.143.91d07e8cdd5c4b9e4731.js} +4 -4
- data/assets/javascript/{chunk.178.ca5ade1d8cbdbfbe6d72.js → chunk.178.16d0c9057345120bdba1.js} +3 -3
- data/assets/javascript/client-app.js +4 -2
- data/client-app/app/components/back-trace.js +4 -0
- data/client-app/package.json +1 -1
- data/client-app/preload-json-manager.rb +10 -17
- data/client-app/tests/integration/components/back-trace-test.js +17 -0
- data/client-app/yarn.lock +22 -22
- data/lib/examples/sidekiq_logster_reporter.rb +5 -7
- data/lib/logster/base_store.rb +26 -22
- data/lib/logster/cache.rb +2 -1
- data/lib/logster/configuration.rb +3 -3
- data/lib/logster/defer_logger.rb +2 -4
- data/lib/logster/group.rb +17 -20
- data/lib/logster/ignore_pattern.rb +1 -2
- data/lib/logster/logger.rb +18 -16
- data/lib/logster/message.rb +53 -57
- data/lib/logster/middleware/debug_exceptions.rb +12 -10
- data/lib/logster/middleware/reporter.rb +17 -26
- data/lib/logster/middleware/viewer.rb +77 -97
- data/lib/logster/pattern.rb +4 -7
- data/lib/logster/rails/railtie.rb +10 -13
- data/lib/logster/redis_rate_limiter.rb +2 -7
- data/lib/logster/redis_store.rb +79 -99
- data/lib/logster/scheduler.rb +1 -5
- data/lib/logster/suppression_pattern.rb +7 -5
- data/lib/logster/version.rb +1 -1
- data/lib/logster/web.rb +1 -1
- data/lib/logster.rb +15 -17
- data/logster.gemspec +14 -14
- data/test/examples/test_sidekiq_reporter_example.rb +8 -9
- data/test/fake_data/generate.rb +14 -3
- data/test/logster/middleware/test_reporter.rb +9 -7
- data/test/logster/middleware/test_viewer.rb +117 -101
- data/test/logster/test_base_store.rb +79 -58
- data/test/logster/test_cache.rb +5 -11
- data/test/logster/test_defer_logger.rb +3 -3
- data/test/logster/test_group.rb +14 -18
- data/test/logster/test_ignore_pattern.rb +2 -3
- data/test/logster/test_logger.rb +14 -14
- data/test/logster/test_message.rb +29 -31
- data/test/logster/test_pattern.rb +7 -15
- data/test/logster/test_redis_rate_limiter.rb +35 -21
- data/test/logster/test_redis_store.rb +239 -151
- data/test/test_helper.rb +9 -9
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b69420ed949004c6a66f47104e4a0e7e2849038230ae775f8c60d3f5a38dd08d
|
4
|
+
data.tar.gz: feb7b7e9f010b4e817a85cea34f5b631219645f4865ff3dc693a845adbebd916
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c066d38fad5f96b100052151126c476e911d969f35805e8853fbb605ca2c31a9ddcc7049452f652a9b6b8ca073c45c0c71a9c45030d866d090d4c023f2f1243
|
7
|
+
data.tar.gz: 889cc20bb7e373ef89ee81b70d29d4bf0d8d7465c965be8250f26bc6111c8df5c83eb75e439e5ee4c254666a5cc7db849132849926ce84928f70bc5a67dff3d6
|
data/.github/workflows/ci.yml
CHANGED
@@ -92,6 +92,11 @@ jobs:
|
|
92
92
|
working-directory: client-app
|
93
93
|
run: yarn install
|
94
94
|
|
95
|
+
- name: Syntax Tree
|
96
|
+
if: ${{ !cancelled() }}
|
97
|
+
run: |
|
98
|
+
bundle exec stree check Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake') $(git ls-files '*.thor')
|
99
|
+
|
95
100
|
- name: JS linting
|
96
101
|
if: ${{ !cancelled() }}
|
97
102
|
working-directory: client-app
|
data/.streerc
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
- 2023-
|
3
|
+
- 2023-10-03: 2.13.0
|
4
|
+
|
5
|
+
- FEATURE: Format messages with Logster::Logger#formatter before storing
|
6
|
+
|
7
|
+
- 2023-03-10: 2.12.2
|
8
|
+
|
9
|
+
- FIX: Don't throw on non-gem backtrace lines
|
10
|
+
|
11
|
+
- 2023-03-10: 2.12.1
|
12
|
+
Note: 2.12.0 was yanked due to a release process error
|
4
13
|
|
5
14
|
- DEV: Upgrade to Ember 3.28
|
6
15
|
|
data/Gemfile
CHANGED
data/assets/javascript/{chunk.143.2faa04830259ce9aa59a.js → chunk.143.91d07e8cdd5c4b9e4731.js}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
var __ember_auto_import__
|
2
|
-
!function(){var e,r={
|
3
|
-
e.exports=(o=_eai_d,t=_eai_r,window.emberAutoImportDynamic=function(e){return 1===arguments.length?t("_eai_dyn_"+e):t("_eai_dynt_"+e)(Array.prototype.slice.call(arguments,1))},window.emberAutoImportSync=function(e){return t("_eai_sync_"+e)(Array.prototype.slice.call(arguments,1))},o("__v1-addons__early-boot-set__",[],(function(){})),void o("sinon",["__v1-addons__early-boot-set__"],(function(){return n(468)})))},
|
2
|
+
!function(){var e,r={29:function(e,r,n){var o,t
|
3
|
+
e.exports=(o=_eai_d,t=_eai_r,window.emberAutoImportDynamic=function(e){return 1===arguments.length?t("_eai_dyn_"+e):t("_eai_dynt_"+e)(Array.prototype.slice.call(arguments,1))},window.emberAutoImportSync=function(e){return t("_eai_sync_"+e)(Array.prototype.slice.call(arguments,1))},o("__v1-addons__early-boot-set__",[],(function(){})),void o("sinon",["__v1-addons__early-boot-set__"],(function(){return n(468)})))},236:function(e,r){window._eai_r=require,window._eai_d=define}},n={}
|
4
4
|
function o(e){var t=n[e]
|
5
5
|
if(void 0!==t)return t.exports
|
6
6
|
var i=n[e]={exports:{}}
|
@@ -17,6 +17,6 @@ var r=function(r,n){var t,i,u=n[0],_=n[1],a=n[2],f=0
|
|
17
17
|
if(u.some((function(r){return 0!==e[r]}))){for(t in _)o.o(_,t)&&(o.m[t]=_[t])
|
18
18
|
if(a)var c=a(o)}for(r&&r(n);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0
|
19
19
|
return o.O(c)},n=self.webpackChunk_ember_auto_import_=self.webpackChunk_ember_auto_import_||[]
|
20
|
-
n.forEach(r.bind(null,0)),n.push=r.bind(null,n.push.bind(n))}(),o.O(void 0,[468],(function(){return o(
|
21
|
-
var t=o.O(void 0,[468],(function(){return o(
|
20
|
+
n.forEach(r.bind(null,0)),n.push=r.bind(null,n.push.bind(n))}(),o.O(void 0,[468],(function(){return o(236)}))
|
21
|
+
var t=o.O(void 0,[468],(function(){return o(29)}))
|
22
22
|
t=o.O(t),__ember_auto_import__=t}()
|
data/assets/javascript/{chunk.178.ca5ade1d8cbdbfbe6d72.js → chunk.178.16d0c9057345120bdba1.js}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
var __ember_auto_import__
|
2
|
-
!function(){var r,n={
|
2
|
+
!function(){var r,n={236:function(r,n){window._eai_r=require,window._eai_d=define},531:function(r,n,e){var t,o
|
3
3
|
r.exports=(t=_eai_d,o=_eai_r,window.emberAutoImportDynamic=function(r){return 1===arguments.length?o("_eai_dyn_"+r):o("_eai_dynt_"+r)(Array.prototype.slice.call(arguments,1))},window.emberAutoImportSync=function(r){return o("_eai_sync_"+r)(Array.prototype.slice.call(arguments,1))},t("__v1-addons__early-boot-set__",[],(function(){})),void t("qunit",["__v1-addons__early-boot-set__"],(function(){return e(916)})))}},e={}
|
4
4
|
function t(r){var o=e[r]
|
5
5
|
if(void 0!==o)return o.exports
|
@@ -17,6 +17,6 @@ var n=function(n,e){var o,i,_=e[0],u=e[1],a=e[2],c=0
|
|
17
17
|
if(_.some((function(n){return 0!==r[n]}))){for(o in u)t.o(u,o)&&(t.m[o]=u[o])
|
18
18
|
if(a)var f=a(t)}for(n&&n(e);c<_.length;c++)i=_[c],t.o(r,i)&&r[i]&&r[i][0](),r[i]=0
|
19
19
|
return t.O(f)},e=self.webpackChunk_ember_auto_import_=self.webpackChunk_ember_auto_import_||[]
|
20
|
-
e.forEach(n.bind(null,0)),e.push=n.bind(null,e.push.bind(e))}(),t.O(void 0,[916],(function(){return t(
|
21
|
-
var o=t.O(void 0,[916],(function(){return t(
|
20
|
+
e.forEach(n.bind(null,0)),e.push=n.bind(null,e.push.bind(e))}(),t.O(void 0,[916],(function(){return t(236)}))
|
21
|
+
var o=t.O(void 0,[916],(function(){return t(531)}))
|
22
22
|
o=t.O(o),__ember_auto_import__=o}()
|
@@ -86,7 +86,9 @@ return Array.isArray(this.env)?e=this.env.map((function(e){return e.application_
|
|
86
86
|
return this.backtrace&&0!==this.backtrace.length?this.backtrace.split("\n").map((function(t){var r=function(e){if(e.startsWith(n.default.get("gems_dir"))){var t=n.default.get("gems_dir")
|
87
87
|
return e.substring(t.length)}return e}(t)
|
88
88
|
return{line:r,url:e.findGithubURL(t,r)}})):[]}},{key:"githubURLForGem",value:function(e){if(!n.default.get("backtrace_links_enabled"))return null
|
89
|
-
var t=c(e.match(/([^/]+)\/(.+\/)(.+):(\d+):.*/)||[],5),r=t[1],o=t[2],i=t[3],a=t[4]
|
89
|
+
var t=c(e.match(/([^/]+)\/(.+\/)(.+):(\d+):.*/)||[],5),r=t[1],o=t[2],i=t[3],a=t[4]
|
90
|
+
if(!r)return null
|
91
|
+
var u=n.default.get("gems_data").filter((function(e){return r.startsWith("".concat(e.name,"-"))})).sortBy("name.length").reverse()[0]
|
90
92
|
return u?h({repo:u.url,path:o,filename:i,lineNumber:a}):null}},{key:"githubURLForApp",value:function(e){if(!n.default.get("backtrace_links_enabled"))return null
|
91
93
|
var t=n.default.get("directories").filter((function(t){return e.startsWith(t.path)})).sortBy("path.length").reverse()[0]
|
92
94
|
if(!t)return null
|
@@ -1279,4 +1281,4 @@ var r=(0,t.createTemplateFactory)({id:"qqSpoh9d",block:'[[[10,0],[14,0,"settings
|
|
1279
1281
|
e.default=r})),define("client-app/templates/show",["exports","@ember/template-factory"],(function(e,t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
|
1280
1282
|
var r=(0,t.createTemplateFactory)({id:"Wi+UDSYU",block:'[[[8,[39,0],[[24,0,"recent-link"]],[["@route"],["index"]],[["default"],[[[[1,"Recent"]],[]]]]],[1,"\\n\\n"],[10,0],[14,1,"bottom-panel"],[14,0,"full"],[12],[1,"\\n "],[8,[39,1],null,[["@currentMessage","@showTitle","@envChangedAction","@currentEnvPosition","@actionsInMenu"],[[30,0,["model"]],"true",[30,0,["envChanged"]],[30,0,["envPosition"]],false]],null],[1,"\\n"],[13]],[],false,["link-to","message-info"]]',moduleName:"client-app/templates/show.hbs",isStrictMode:!1})
|
1281
1283
|
e.default=r})),define("client-app/config/environment",[],(function(){try{var e="client-app/config/environment",t=document.querySelector('meta[name="'+e+'"]').getAttribute("content"),r={default:JSON.parse(decodeURIComponent(t))}
|
1282
|
-
return Object.defineProperty(r,"__esModule",{value:!0}),r}catch(n){throw new Error('Could not read config from meta tag with name "'+e+'".')}})),runningTests||require("client-app/app").default.create({name:"client-app",version:"0.0.0+
|
1284
|
+
return Object.defineProperty(r,"__esModule",{value:!0}),r}catch(n){throw new Error('Could not read config from meta tag with name "'+e+'".')}})),runningTests||require("client-app/app").default.create({name:"client-app",version:"0.0.0+1c8d3d18"})
|
@@ -76,6 +76,10 @@ export default class BackTrace extends Component {
|
|
76
76
|
|
77
77
|
const regexResults = line.match(/([^/]+)\/(.+\/)(.+):(\d+):.*/);
|
78
78
|
const [, gemWithVersion, path, filename, lineNumber] = regexResults || [];
|
79
|
+
if (!gemWithVersion) {
|
80
|
+
return null;
|
81
|
+
}
|
82
|
+
|
79
83
|
const gemsData = Preloaded.get("gems_data");
|
80
84
|
const match = gemsData
|
81
85
|
.filter((g) => gemWithVersion.startsWith(`${g.name}-`))
|
data/client-app/package.json
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
# This script takes care of updating the content of the preloaded json in tests/index.html
|
4
4
|
# All you need to do is update the `tests_index_html` hash and run the script
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require "bundler/inline"
|
7
|
+
require "json"
|
8
|
+
require "cgi"
|
9
9
|
|
10
10
|
gemfile do
|
11
|
-
source
|
12
|
-
gem
|
11
|
+
source "https://rubygems.org"
|
12
|
+
gem "nokogiri"
|
13
13
|
end
|
14
14
|
|
15
15
|
tests_index_html = {
|
@@ -17,23 +17,16 @@ tests_index_html = {
|
|
17
17
|
gems_dir: "/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/",
|
18
18
|
backtrace_links_enabled: true,
|
19
19
|
gems_data: [
|
20
|
-
{
|
21
|
-
name: "activerecord",
|
22
|
-
url: "https://github.com/rails/rails/tree/v6.0.1/activerecord"
|
23
|
-
}
|
20
|
+
{ name: "activerecord", url: "https://github.com/rails/rails/tree/v6.0.1/activerecord" },
|
24
21
|
],
|
25
22
|
directories: [
|
26
|
-
{
|
27
|
-
path: "/var/www/discourse",
|
28
|
-
url: "https://github.com/discourse/discourse",
|
29
|
-
main_app: true
|
30
|
-
},
|
23
|
+
{ path: "/var/www/discourse", url: "https://github.com/discourse/discourse", main_app: true },
|
31
24
|
{
|
32
25
|
path: "/var/www/discourse/plugins/discourse-prometheus",
|
33
|
-
url: "https://github.com/discourse/discourse-prometheus"
|
34
|
-
}
|
26
|
+
url: "https://github.com/discourse/discourse-prometheus",
|
27
|
+
},
|
35
28
|
],
|
36
|
-
application_version: "ce512452b512b909c38e9c63f2a0e1f8c17a2399"
|
29
|
+
application_version: "ce512452b512b909c38e9c63f2a0e1f8c17a2399",
|
37
30
|
}
|
38
31
|
|
39
32
|
content = File.read("tests/index.html")
|
@@ -66,6 +66,23 @@ string@https://discourse-cdn.com/assets/application-f59d2.br.js:1:27869`
|
|
66
66
|
});
|
67
67
|
});
|
68
68
|
|
69
|
+
test("non-gem backtraces don't break things", async function (assert) {
|
70
|
+
this.set(
|
71
|
+
"backtrace",
|
72
|
+
`/ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/behaviors.rb:33:in \`block in <class:Deprecation>'
|
73
|
+
/ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:26:in \`block (2 levels) in warn'
|
74
|
+
/ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:26:in \`each'
|
75
|
+
/ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:26:in \`block in warn'
|
76
|
+
<internal:kernel>:90:in \`tap'
|
77
|
+
/ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:22:in \`warn'`
|
78
|
+
);
|
79
|
+
await render(hbs`<BackTrace @backtrace={{this.backtrace}} />`);
|
80
|
+
const lines = this.backtrace.split("\n");
|
81
|
+
findAll("div.backtrace-line").forEach((node, index) => {
|
82
|
+
assert.strictEqual(node.textContent.trim(), lines[index]);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
69
86
|
test("Github links use commit sha", async function (assert) {
|
70
87
|
const backtrace = `/var/www/discourse/lib/permalink_constraint.rb:6:in \`matches?'`;
|
71
88
|
let env = [
|
data/client-app/yarn.lock
CHANGED
@@ -4275,9 +4275,9 @@ engine.io-parser@~5.0.3:
|
|
4275
4275
|
integrity sha512-tjuoZDMAdEhVnSFleYPCtdL2GXwVTGtNjoeJd9IhIG3C1xs9uwxqRNEu5WpnDZCaozwVlK/nuQhpodhXSIMaxw==
|
4276
4276
|
|
4277
4277
|
engine.io@~6.4.1:
|
4278
|
-
version "6.4.
|
4279
|
-
resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.4.
|
4280
|
-
integrity sha512-
|
4278
|
+
version "6.4.2"
|
4279
|
+
resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.4.2.tgz#ffeaf68f69b1364b0286badddf15ff633476473f"
|
4280
|
+
integrity sha512-FKn/3oMiJjrOEOeUub2WCox6JhxBXq/Zn3fZOMCBxKnNYtsdKjxhl7yR3fZhM9PV+rdE75SU5SYMc+2PGzo+Tg==
|
4281
4281
|
dependencies:
|
4282
4282
|
"@types/cookie" "^0.4.1"
|
4283
4283
|
"@types/cors" "^2.8.12"
|
@@ -8268,19 +8268,19 @@ schema-utils@^4.0.0:
|
|
8268
8268
|
ajv-keywords "^5.0.0"
|
8269
8269
|
|
8270
8270
|
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0:
|
8271
|
-
version "5.7.
|
8272
|
-
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.
|
8273
|
-
integrity sha512-
|
8271
|
+
version "5.7.2"
|
8272
|
+
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
|
8273
|
+
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==
|
8274
8274
|
|
8275
8275
|
semver@^6.0.0, semver@^6.1.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
|
8276
|
-
version "6.3.
|
8277
|
-
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.
|
8278
|
-
integrity sha512-
|
8276
|
+
version "6.3.1"
|
8277
|
+
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
8278
|
+
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
8279
8279
|
|
8280
8280
|
semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.8:
|
8281
|
-
version "7.
|
8282
|
-
resolved "https://registry.yarnpkg.com/semver/-/semver-7.
|
8283
|
-
integrity sha512-
|
8281
|
+
version "7.5.4"
|
8282
|
+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
|
8283
|
+
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
|
8284
8284
|
dependencies:
|
8285
8285
|
lru-cache "^6.0.0"
|
8286
8286
|
|
@@ -8478,9 +8478,9 @@ socket.io-adapter@~2.5.2:
|
|
8478
8478
|
ws "~8.11.0"
|
8479
8479
|
|
8480
8480
|
socket.io-parser@~4.2.1:
|
8481
|
-
version "4.2.
|
8482
|
-
resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.
|
8483
|
-
integrity sha512-
|
8481
|
+
version "4.2.3"
|
8482
|
+
resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.3.tgz#926bcc6658e2ae0883dc9dee69acbdc76e4e3667"
|
8483
|
+
integrity sha512-JMafRntWVO2DCJimKsRTh/wnqVvO4hrfwOqtO7f+uzwsQMuxO6VwImtYxaQ+ieoyshWOTJyV0fA21lccEXRPpQ==
|
8484
8484
|
dependencies:
|
8485
8485
|
"@socket.io/component-emitter" "~3.1.0"
|
8486
8486
|
debug "~4.3.1"
|
@@ -9447,10 +9447,10 @@ webpack-sources@^3.2.3:
|
|
9447
9447
|
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
|
9448
9448
|
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==
|
9449
9449
|
|
9450
|
-
webpack@^5.
|
9451
|
-
version "5.
|
9452
|
-
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.
|
9453
|
-
integrity sha512-
|
9450
|
+
webpack@^5.76.0:
|
9451
|
+
version "5.76.0"
|
9452
|
+
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c"
|
9453
|
+
integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==
|
9454
9454
|
dependencies:
|
9455
9455
|
"@types/eslint-scope" "^3.7.3"
|
9456
9456
|
"@types/estree" "^0.0.51"
|
@@ -9554,9 +9554,9 @@ wide-align@^1.1.5:
|
|
9554
9554
|
string-width "^1.0.2 || 2 || 3 || 4"
|
9555
9555
|
|
9556
9556
|
word-wrap@^1.2.3:
|
9557
|
-
version "1.2.
|
9558
|
-
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.
|
9559
|
-
integrity sha512-
|
9557
|
+
version "1.2.4"
|
9558
|
+
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f"
|
9559
|
+
integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==
|
9560
9560
|
|
9561
9561
|
wordwrap@^0.0.3:
|
9562
9562
|
version "0.0.3"
|
@@ -4,19 +4,17 @@ class SidekiqLogsterReporter
|
|
4
4
|
def call(ex, context = {})
|
5
5
|
# Pass context to Logster
|
6
6
|
fake_env = {}
|
7
|
-
context.each
|
8
|
-
Logster.add_to_env(fake_env, key, value)
|
9
|
-
end
|
7
|
+
context.each { |key, value| Logster.add_to_env(fake_env, key, value) }
|
10
8
|
|
11
9
|
text = "Job exception: #{ex}\n"
|
12
|
-
if ex.backtrace
|
13
|
-
Logster.add_to_env(fake_env, :backtrace, ex.backtrace)
|
14
|
-
end
|
10
|
+
Logster.add_to_env(fake_env, :backtrace, ex.backtrace) if ex.backtrace
|
15
11
|
|
16
12
|
Thread.current[Logster::Logger::LOGSTER_ENV] = fake_env
|
17
13
|
Logster.logger.error(text)
|
18
14
|
rescue => e
|
19
|
-
Logster.logger.fatal(
|
15
|
+
Logster.logger.fatal(
|
16
|
+
"Failed to log exception #{ex} #{hash}\nReason: #{e.class} #{e}\n#{e.backtrace.join("\n")}",
|
17
|
+
)
|
20
18
|
ensure
|
21
19
|
Thread.current[Logster::Logger::LOGSTER_ENV] = nil
|
22
20
|
end
|
data/lib/logster/base_store.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Logster
|
4
4
|
class BaseStore
|
5
|
-
|
6
5
|
attr_accessor :level, :max_retention, :skip_empty, :ignore, :allow_custom_patterns
|
7
6
|
|
8
7
|
def initialize
|
@@ -166,31 +165,35 @@ module Logster
|
|
166
165
|
message.populate_from_env(env)
|
167
166
|
|
168
167
|
if backtrace
|
169
|
-
if backtrace.respond_to? :join
|
170
|
-
backtrace = backtrace.join("\n")
|
171
|
-
end
|
168
|
+
backtrace = backtrace.join("\n") if backtrace.respond_to? :join
|
172
169
|
message.backtrace = backtrace
|
173
170
|
else
|
174
171
|
message.backtrace = caller.join("\n")
|
175
172
|
end
|
176
173
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
174
|
+
if ignore &&
|
175
|
+
ignore.any? { |pattern|
|
176
|
+
if message =~ pattern
|
177
|
+
val = Regexp === pattern ? pattern.inspect : pattern.to_s
|
178
|
+
increment_ignore_count(val)
|
179
|
+
true
|
180
|
+
end
|
181
|
+
}
|
182
|
+
return
|
183
183
|
end
|
184
184
|
|
185
185
|
if Logster.config.enable_custom_patterns_via_ui || allow_custom_patterns
|
186
|
-
custom_ignore =
|
187
|
-
Logster::SuppressionPattern
|
188
|
-
|
189
|
-
return if custom_ignore.any? do |pattern|
|
190
|
-
if message =~ pattern
|
191
|
-
increment_ignore_count(pattern.inspect)
|
192
|
-
true
|
186
|
+
custom_ignore =
|
187
|
+
@patterns_cache.fetch(Logster::SuppressionPattern::CACHE_KEY) do
|
188
|
+
Logster::SuppressionPattern.find_all(store: self)
|
193
189
|
end
|
190
|
+
if custom_ignore.any? { |pattern|
|
191
|
+
if message =~ pattern
|
192
|
+
increment_ignore_count(pattern.inspect)
|
193
|
+
true
|
194
|
+
end
|
195
|
+
}
|
196
|
+
return
|
194
197
|
end
|
195
198
|
end
|
196
199
|
|
@@ -199,7 +202,7 @@ module Logster
|
|
199
202
|
if Logster.config.allow_grouping
|
200
203
|
message.apply_message_size_limit(
|
201
204
|
Logster.config.maximum_message_size_bytes,
|
202
|
-
gems_dir: Logster.config.gems_dir
|
205
|
+
gems_dir: Logster.config.gems_dir,
|
203
206
|
)
|
204
207
|
key = self.similar_key(message)
|
205
208
|
similar = get(key, load_env: false) if key
|
@@ -215,7 +218,7 @@ module Logster
|
|
215
218
|
else
|
216
219
|
message.apply_message_size_limit(
|
217
220
|
Logster.config.maximum_message_size_bytes,
|
218
|
-
gems_dir: Logster.config.gems_dir
|
221
|
+
gems_dir: Logster.config.gems_dir,
|
219
222
|
)
|
220
223
|
saved = save(message)
|
221
224
|
message
|
@@ -224,9 +227,10 @@ module Logster
|
|
224
227
|
message = similar || message
|
225
228
|
|
226
229
|
if (Logster.config.enable_custom_patterns_via_ui || allow_custom_patterns) && saved
|
227
|
-
grouping_patterns =
|
228
|
-
Logster::GroupingPattern
|
229
|
-
|
230
|
+
grouping_patterns =
|
231
|
+
@patterns_cache.fetch(Logster::GroupingPattern::CACHE_KEY) do
|
232
|
+
Logster::GroupingPattern.find_all(store: self)
|
233
|
+
end
|
230
234
|
|
231
235
|
grouping_patterns.each do |pattern|
|
232
236
|
if message =~ pattern
|
data/lib/logster/cache.rb
CHANGED
@@ -8,7 +8,8 @@ module Logster
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def fetch(key)
|
11
|
-
if !@hash.key?(key) ||
|
11
|
+
if !@hash.key?(key) ||
|
12
|
+
@hash[key][:created_at] + @age < Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
12
13
|
@hash[key] = { data: yield, created_at: Process.clock_gettime(Process::CLOCK_MONOTONIC) }
|
13
14
|
end
|
14
15
|
@hash[key][:data]
|
@@ -19,7 +19,7 @@ module Logster
|
|
19
19
|
:max_env_bytes,
|
20
20
|
:max_env_count_per_message,
|
21
21
|
:maximum_message_length,
|
22
|
-
:use_full_hostname
|
22
|
+
:use_full_hostname,
|
23
23
|
)
|
24
24
|
|
25
25
|
attr_writer :subdirectory
|
@@ -27,7 +27,7 @@ module Logster
|
|
27
27
|
def initialize
|
28
28
|
# lambda |env,block|
|
29
29
|
@current_context = lambda { |_, &block| block.call }
|
30
|
-
@environments = [
|
30
|
+
@environments = %i[development production]
|
31
31
|
@subdirectory = nil
|
32
32
|
@env_expandable_keys = []
|
33
33
|
@enable_custom_patterns_via_ui = false
|
@@ -50,7 +50,7 @@ module Logster
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def subdirectory
|
53
|
-
@subdirectory ||
|
53
|
+
@subdirectory || "/logs"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/logster/defer_logger.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "logster/scheduler"
|
4
4
|
|
5
5
|
module Logster
|
6
6
|
class DeferLogger < ::Logster::Logger
|
@@ -8,9 +8,7 @@ module Logster
|
|
8
8
|
|
9
9
|
def report_to_store(severity, progname, message, opts = {})
|
10
10
|
opts[:backtrace] ||= caller.join("\n")
|
11
|
-
Logster::Scheduler.schedule
|
12
|
-
super(severity, progname, message, opts)
|
13
|
-
end
|
11
|
+
Logster::Scheduler.schedule { super(severity, progname, message, opts) }
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
data/lib/logster/group.rb
CHANGED
@@ -17,12 +17,13 @@ module Logster
|
|
17
17
|
|
18
18
|
def self.from_json(json)
|
19
19
|
hash = JSON.parse(json)
|
20
|
-
group =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
group =
|
21
|
+
new(
|
22
|
+
hash["key"],
|
23
|
+
hash["messages_keys"],
|
24
|
+
timestamp: hash["timestamp"] || 0,
|
25
|
+
count: hash["count"] || 0,
|
26
|
+
)
|
26
27
|
group.changed = false
|
27
28
|
group
|
28
29
|
end
|
@@ -32,12 +33,7 @@ module Logster
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def to_h
|
35
|
-
{
|
36
|
-
key: @key,
|
37
|
-
messages_keys: @messages_keys,
|
38
|
-
timestamp: @timestamp,
|
39
|
-
count: @count
|
40
|
-
}
|
36
|
+
{ key: @key, messages_keys: @messages_keys, timestamp: @timestamp, count: @count }
|
41
37
|
end
|
42
38
|
|
43
39
|
def to_h_web
|
@@ -47,7 +43,7 @@ module Logster
|
|
47
43
|
timestamp: @timestamp,
|
48
44
|
messages: @messages,
|
49
45
|
severity: -1,
|
50
|
-
group: true
|
46
|
+
group: true,
|
51
47
|
}
|
52
48
|
end
|
53
49
|
|
@@ -111,14 +107,15 @@ module Logster
|
|
111
107
|
self.class.max_size
|
112
108
|
end
|
113
109
|
|
114
|
-
GroupWeb =
|
115
|
-
|
116
|
-
|
117
|
-
|
110
|
+
GroupWeb =
|
111
|
+
Struct.new(*%i[regex count timestamp messages row_id]) do
|
112
|
+
def to_json(opts = nil)
|
113
|
+
JSON.fast_generate(self.to_h.merge(severity: -1, group: true), opts)
|
114
|
+
end
|
118
115
|
|
119
|
-
|
120
|
-
|
116
|
+
def key
|
117
|
+
self.regex # alias for testing convenience
|
118
|
+
end
|
121
119
|
end
|
122
|
-
end
|
123
120
|
end
|
124
121
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Logster
|
4
4
|
class IgnorePattern
|
5
|
-
|
6
5
|
def initialize(message_pattern = nil, env_patterns = nil)
|
7
6
|
@msg_match = message_pattern
|
8
7
|
@env_match = env_patterns
|
@@ -44,7 +43,7 @@ module Logster
|
|
44
43
|
else
|
45
44
|
false
|
46
45
|
end
|
47
|
-
|
46
|
+
else
|
48
47
|
false
|
49
48
|
end
|
50
49
|
end
|
data/lib/logster/logger.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "logger"
|
4
4
|
|
5
5
|
module Logster
|
6
6
|
class Logger < ::Logger
|
@@ -41,9 +41,7 @@ module Logster
|
|
41
41
|
logger.add(severity, message, progname, &block)
|
42
42
|
end
|
43
43
|
ensure
|
44
|
-
if logger.respond_to? :skip_store
|
45
|
-
logger.skip_store = old
|
46
|
-
end
|
44
|
+
logger.skip_store = old if logger.respond_to? :skip_store
|
47
45
|
end
|
48
46
|
|
49
47
|
def add(*args, &block)
|
@@ -55,15 +53,11 @@ module Logster
|
|
55
53
|
end
|
56
54
|
|
57
55
|
def add_with_opts(severity, message = nil, progname = progname(), opts = nil, &block)
|
58
|
-
if severity < level
|
59
|
-
return true
|
60
|
-
end
|
56
|
+
return true if severity < level
|
61
57
|
|
62
58
|
# it is not fun losing messages cause encoding is bad
|
63
59
|
# protect all messages by scrubbing if needed
|
64
|
-
if message && !message.valid_encoding?
|
65
|
-
message = message.scrub
|
66
|
-
end
|
60
|
+
message = message.scrub if message && !message.valid_encoding?
|
67
61
|
|
68
62
|
# we want to get the backtrace as early as possible so that logster's
|
69
63
|
# own methods don't show up as the first few frames in the backtrace
|
@@ -73,9 +67,7 @@ module Logster
|
|
73
67
|
backtrace ||= progname.backtrace if progname.kind_of?(::Exception)
|
74
68
|
if !backtrace
|
75
69
|
backtrace = caller_locations
|
76
|
-
while backtrace.first.path.end_with?("/logger.rb")
|
77
|
-
backtrace.shift
|
78
|
-
end
|
70
|
+
backtrace.shift while backtrace.first.path.end_with?("/logger.rb")
|
79
71
|
end
|
80
72
|
backtrace = backtrace.join("\n")
|
81
73
|
opts[:backtrace] = backtrace
|
@@ -90,12 +82,18 @@ module Logster
|
|
90
82
|
add_to_chained(@chained[i], severity, message, progname, opts, &block)
|
91
83
|
rescue => e
|
92
84
|
# don't blow up if STDERR is somehow closed
|
93
|
-
|
85
|
+
begin
|
86
|
+
STDERR.puts "Failed to report message to chained logger #{e}"
|
87
|
+
rescue StandardError
|
88
|
+
nil
|
89
|
+
end
|
94
90
|
end
|
95
91
|
i += 1
|
96
92
|
end
|
97
93
|
end
|
98
94
|
|
95
|
+
return if @skip_store
|
96
|
+
|
99
97
|
progname ||= @progname
|
100
98
|
if message.nil?
|
101
99
|
if block_given?
|
@@ -106,7 +104,7 @@ module Logster
|
|
106
104
|
end
|
107
105
|
end
|
108
106
|
|
109
|
-
|
107
|
+
message = formatter.call(severity, Time.now, progname, message) if formatter
|
110
108
|
|
111
109
|
opts ||= {}
|
112
110
|
opts[:env] ||= Thread.current[LOGSTER_ENV]
|
@@ -114,7 +112,11 @@ module Logster
|
|
114
112
|
report_to_store(severity, progname, message, opts)
|
115
113
|
rescue => e
|
116
114
|
# don't blow up if STDERR is somehow closed
|
117
|
-
|
115
|
+
begin
|
116
|
+
STDERR.puts "Failed to report error: #{e} #{severity} #{message} #{progname}"
|
117
|
+
rescue StandardError
|
118
|
+
nil
|
119
|
+
end
|
118
120
|
end
|
119
121
|
|
120
122
|
private
|