logster 2.12.1 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +5 -0
  3. data/.streerc +2 -0
  4. data/CHANGELOG.md +10 -1
  5. data/Gemfile +1 -1
  6. data/assets/javascript/{chunk.143.2faa04830259ce9aa59a.js → chunk.143.91d07e8cdd5c4b9e4731.js} +4 -4
  7. data/assets/javascript/{chunk.178.ca5ade1d8cbdbfbe6d72.js → chunk.178.16d0c9057345120bdba1.js} +3 -3
  8. data/assets/javascript/client-app.js +4 -2
  9. data/client-app/app/components/back-trace.js +4 -0
  10. data/client-app/package.json +1 -1
  11. data/client-app/preload-json-manager.rb +10 -17
  12. data/client-app/tests/integration/components/back-trace-test.js +17 -0
  13. data/client-app/yarn.lock +22 -22
  14. data/lib/examples/sidekiq_logster_reporter.rb +5 -7
  15. data/lib/logster/base_store.rb +26 -22
  16. data/lib/logster/cache.rb +2 -1
  17. data/lib/logster/configuration.rb +3 -3
  18. data/lib/logster/defer_logger.rb +2 -4
  19. data/lib/logster/group.rb +17 -20
  20. data/lib/logster/ignore_pattern.rb +1 -2
  21. data/lib/logster/logger.rb +18 -16
  22. data/lib/logster/message.rb +53 -57
  23. data/lib/logster/middleware/debug_exceptions.rb +12 -10
  24. data/lib/logster/middleware/reporter.rb +17 -26
  25. data/lib/logster/middleware/viewer.rb +77 -97
  26. data/lib/logster/pattern.rb +4 -7
  27. data/lib/logster/rails/railtie.rb +10 -13
  28. data/lib/logster/redis_rate_limiter.rb +2 -7
  29. data/lib/logster/redis_store.rb +79 -99
  30. data/lib/logster/scheduler.rb +1 -5
  31. data/lib/logster/suppression_pattern.rb +7 -5
  32. data/lib/logster/version.rb +1 -1
  33. data/lib/logster/web.rb +1 -1
  34. data/lib/logster.rb +15 -17
  35. data/logster.gemspec +14 -14
  36. data/test/examples/test_sidekiq_reporter_example.rb +8 -9
  37. data/test/fake_data/generate.rb +14 -3
  38. data/test/logster/middleware/test_reporter.rb +9 -7
  39. data/test/logster/middleware/test_viewer.rb +117 -101
  40. data/test/logster/test_base_store.rb +79 -58
  41. data/test/logster/test_cache.rb +5 -11
  42. data/test/logster/test_defer_logger.rb +3 -3
  43. data/test/logster/test_group.rb +14 -18
  44. data/test/logster/test_ignore_pattern.rb +2 -3
  45. data/test/logster/test_logger.rb +14 -14
  46. data/test/logster/test_message.rb +29 -31
  47. data/test/logster/test_pattern.rb +7 -15
  48. data/test/logster/test_redis_rate_limiter.rb +35 -21
  49. data/test/logster/test_redis_store.rb +239 -151
  50. data/test/test_helper.rb +9 -9
  51. metadata +19 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5d4640abe80e2cf5a80e7f2f11e6419b00a32130b35d62c05564d33e4ecf530
4
- data.tar.gz: a974a5a37f0c210d804d97e496819189c331d5f10b426fee6b831345a289e68a
3
+ metadata.gz: b69420ed949004c6a66f47104e4a0e7e2849038230ae775f8c60d3f5a38dd08d
4
+ data.tar.gz: feb7b7e9f010b4e817a85cea34f5b631219645f4865ff3dc693a845adbebd916
5
5
  SHA512:
6
- metadata.gz: c0a4ce41d8e47036447f2849d8cbafc71982c0164164562174fa8ef7a5a1a446d4f55f38eef6240404ce2ff23ae0ba451672ae3331a718a6d6e7535135ecc36d
7
- data.tar.gz: 8acd7e2d037f7713d28b3dd1cbcc7624201016d398010b9e0dfb7806b4483100ec9fa502a7658a01b2fd5e18b095cb8de140337e28aad95b23a7925fcfd167f7
6
+ metadata.gz: 4c066d38fad5f96b100052151126c476e911d969f35805e8853fbb605ca2c31a9ddcc7049452f652a9b6b8ca073c45c0c71a9c45030d866d090d4c023f2f1243
7
+ data.tar.gz: 889cc20bb7e373ef89ee81b70d29d4bf0d8d7465c965be8250f26bc6111c8df5c83eb75e439e5ee4c254666a5cc7db849132849926ce84928f70bc5a67dff3d6
@@ -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
@@ -0,0 +1,2 @@
1
+ --print-width=100
2
+ --plugins=plugin/trailing_comma
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
- - 2023-03-03: 2.12.0
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in rack-log-viewer.gemspec
6
6
  gemspec
@@ -1,6 +1,6 @@
1
1
  var __ember_auto_import__
2
- !function(){var e,r={976: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)})))},249:function(e,r){window._eai_r=require,window._eai_d=define}},n={}
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(249)}))
21
- var t=o.O(void 0,[468],(function(){return o(976)}))
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}()
@@ -1,5 +1,5 @@
1
1
  var __ember_auto_import__
2
- !function(){var r,n={249:function(r,n){window._eai_r=require,window._eai_d=define},489:function(r,n,e){var t,o
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(249)}))
21
- var o=t.O(void 0,[916],(function(){return t(489)}))
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],u=n.default.get("gems_data").filter((function(e){return r.startsWith("".concat(e.name,"-"))})).sortBy("name.length").reverse()[0]
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+5ec1728b"})
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}-`))
@@ -58,7 +58,7 @@
58
58
  "qunit": "^2.17.2",
59
59
  "qunit-dom": "^2.0.0",
60
60
  "sinon": "^15.0.1",
61
- "webpack": "^5.75.0"
61
+ "webpack": "^5.76.0"
62
62
  },
63
63
  "engines": {
64
64
  "node": "12.* || 14.* || >= 16"
@@ -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 'bundler/inline'
7
- require 'json'
8
- require 'cgi'
6
+ require "bundler/inline"
7
+ require "json"
8
+ require "cgi"
9
9
 
10
10
  gemfile do
11
- source 'https://rubygems.org'
12
- gem 'nokogiri'
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.1"
4279
- resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.4.1.tgz#8056b4526a88e779f9c280d820422d4e3eeaaae5"
4280
- integrity sha512-JFYQurD/nbsA5BSPmbaOSLa3tSVj8L6o4srSwXXY3NqE+gGUNmmPTbhn8tjzcCtSqhFgIeqef81ngny8JM25hw==
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.1"
8272
- resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
8273
- integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
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.0"
8277
- resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
8278
- integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
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.3.8"
8282
- resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
8283
- integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
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.2"
8482
- resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.2.tgz#1dd384019e25b7a3d374877f492ab34f2ad0d206"
8483
- integrity sha512-DJtziuKypFkMMHCm2uIshOYC7QaylbtzQwiMYDuCKy3OPkjLzu4B2vAhTlqipRHHzrI0NJeBAizTK7X+6m1jVw==
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.75.0:
9451
- version "5.75.0"
9452
- resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.75.0.tgz#1e440468647b2505860e94c9ff3e44d5b582c152"
9453
- integrity sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==
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.3"
9558
- resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
9559
- integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
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 do |key, value|
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("Failed to log exception #{ex} #{hash}\nReason: #{e.class} #{e}\n#{e.backtrace.join("\n")}")
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
@@ -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
- return if ignore && ignore.any? do |pattern|
178
- if message =~ pattern
179
- val = Regexp === pattern ? pattern.inspect : pattern.to_s
180
- increment_ignore_count(val)
181
- true
182
- end
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 = @patterns_cache.fetch(Logster::SuppressionPattern::CACHE_KEY) do
187
- Logster::SuppressionPattern.find_all(store: self)
188
- end
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 = @patterns_cache.fetch(Logster::GroupingPattern::CACHE_KEY) do
228
- Logster::GroupingPattern.find_all(store: self)
229
- end
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) || @hash[key][:created_at] + @age < Process.clock_gettime(Process::CLOCK_MONOTONIC)
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 = [:development, :production]
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 || '/logs'
53
+ @subdirectory || "/logs"
54
54
  end
55
55
  end
56
56
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'logster/scheduler'
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 do
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 = new(
21
- hash["key"],
22
- hash["messages_keys"],
23
- timestamp: hash["timestamp"] || 0,
24
- count: hash["count"] || 0
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 = Struct.new(*%i[regex count timestamp messages row_id]) do
115
- def to_json(opts = nil)
116
- JSON.fast_generate(self.to_h.merge(severity: -1, group: true), opts)
117
- end
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
- def key
120
- self.regex # alias for testing convenience
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
- else
46
+ else
48
47
  false
49
48
  end
50
49
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'logger'
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
- STDERR.puts "Failed to report message to chained logger #{e}" rescue nil
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
- return if @skip_store
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
- STDERR.puts "Failed to report error: #{e} #{severity} #{message} #{progname}" rescue nil
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