From e0020aea8a18526809f4f356efa547396c6eb651 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 29 Apr 2026 16:47:02 -0400 Subject: [PATCH 1/8] FEATURE: Allow editing grouping pattern before submitting --- client-app/app/controllers/index.js | 55 +++++++++++++++-------- client-app/app/styles/app.css | 69 +++++++++++++++++++++++++++++ client-app/app/templates/index.hbs | 27 +++++++++++ client-app/ember-cli-build.js | 6 +++ website/Gemfile | 1 + website/Gemfile.lock | 3 ++ 6 files changed, 143 insertions(+), 18 deletions(-) diff --git a/client-app/app/controllers/index.js b/client-app/app/controllers/index.js index 639b7ee1..8bad1890 100644 --- a/client-app/app/controllers/index.js +++ b/client-app/app/controllers/index.js @@ -15,6 +15,8 @@ export default class IndexController extends Controller { @tracked loading = false; @tracked buildingGroupingPattern = false; @tracked rowMessagesForGroupingPattern = []; + @tracked showGroupingPatternDialog = false; + @tracked groupingPatternValue = ""; showDebug = getLocalStorage("showDebug", false); showInfo = getLocalStorage("showInfo", false); @@ -215,32 +217,49 @@ export default class IndexController extends Controller { } @action - async createGroupingPatternFromSelectedRows() { + createGroupingPatternFromSelectedRows() { let match = this.findLongestMatchingPrefix( this.rowMessagesForGroupingPattern ); match = this.escapeRegExp(match); - if ( - match.trim().length && - // eslint-disable-next-line no-alert - confirm( - `Do you want to create the grouping pattern\n\n"${match}"\n\nCancel = No, OK = Create` - ) - ) { - await ajax("/patterns/grouping.json", { - method: "POST", - data: { - pattern: match, - }, - }); - this.rowMessagesForGroupingPattern = []; - this.buildingGroupingPattern = false; - this.model.reload(); - } else if (!match.trim().length) { + if (!match.trim().length) { // eslint-disable-next-line no-alert alert("Can not create a grouping pattern with the given rows"); + return; } + + this.groupingPatternValue = match; + this.showGroupingPatternDialog = true; + } + + @action + updateGroupingPatternValue(event) { + this.groupingPatternValue = event.target.value; + } + + @action + async confirmGroupingPattern() { + const pattern = this.groupingPatternValue.trim(); + if (!pattern.length) { + return; + } + + await ajax("/patterns/grouping.json", { + method: "POST", + data: { pattern }, + }); + this.showGroupingPatternDialog = false; + this.groupingPatternValue = ""; + this.rowMessagesForGroupingPattern = []; + this.buildingGroupingPattern = false; + this.model.reload(); + } + + @action + cancelGroupingPattern() { + this.showGroupingPatternDialog = false; + this.groupingPatternValue = ""; } findLongestMatchingPrefix(strings) { diff --git a/client-app/app/styles/app.css b/client-app/app/styles/app.css index 60f12361..7e63f169 100644 --- a/client-app/app/styles/app.css +++ b/client-app/app/styles/app.css @@ -731,6 +731,60 @@ label span { margin-top: 10px; } +.grouping-pattern-dialog-overlay { + position: fixed; + z-index: 100000; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.5); + display: flex; + align-items: center; + justify-content: center; +} + +.grouping-pattern-dialog { + background: #fff; + border-radius: 4px; + padding: 20px; + min-width: 600px; + box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); +} + +.grouping-pattern-dialog h3 { + margin: 0 0 8px 0; + font-size: 1em; + font-weight: bold; +} + +.grouping-pattern-dialog p { + margin: 0 0 10px 0; + font-size: 0.9em; + color: #555; +} + +.grouping-pattern-input { + width: 100%; + box-sizing: border-box; + padding: 8px; + font-size: 1.1em; + font-family: monospace; + border: 1px solid #ccc; + border-radius: 3px; + margin-bottom: 14px; +} + +.grouping-pattern-dialog-buttons { + display: flex; + justify-content: flex-end; + gap: 8px; +} + +.grouping-pattern-dialog .btn { + padding: 12px; +} + .backtrace-line .line-link { color: #9e9e9e; margin-left: 3px; @@ -826,4 +880,19 @@ label span { #back-to-site-panel { background-color: #181818; } + + .grouping-pattern-dialog { + background: #262626; + color: #cecece; + } + + .grouping-pattern-dialog p { + color: #aaa; + } + + .grouping-pattern-input { + background: #181818; + color: #cecece; + border-color: #555; + } } diff --git a/client-app/app/templates/index.hbs b/client-app/app/templates/index.hbs index 16710509..256bae11 100644 --- a/client-app/app/templates/index.hbs +++ b/client-app/app/templates/index.hbs @@ -162,4 +162,31 @@ +{{#if this.showGroupingPatternDialog}} +
+
+

Create Grouping Pattern

+

Edit the pattern below before creating:

+ +
+ + +
+
+
+{{/if}} + \ No newline at end of file diff --git a/client-app/ember-cli-build.js b/client-app/ember-cli-build.js index 03e336d1..7c2c25b2 100644 --- a/client-app/ember-cli-build.js +++ b/client-app/ember-cli-build.js @@ -1,5 +1,11 @@ "use strict"; +// clean-css v3 uses util.isRegExp which was removed in Node.js 22+ +const util = require("util"); +if (!util.isRegExp) { + util.isRegExp = (value) => value instanceof RegExp; +} + const EmberApp = require("ember-cli/lib/broccoli/ember-app"); module.exports = function (defaults) { diff --git a/website/Gemfile b/website/Gemfile index ea492f23..5146353f 100644 --- a/website/Gemfile +++ b/website/Gemfile @@ -6,3 +6,4 @@ gem 'sinatra' gem 'redis' gem 'logster', path: '../' gem 'puma' +gem 'rackup' diff --git a/website/Gemfile.lock b/website/Gemfile.lock index c38f287b..fc9dcaae 100644 --- a/website/Gemfile.lock +++ b/website/Gemfile.lock @@ -22,6 +22,8 @@ GEM rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) + rackup (2.3.1) + rack (>= 3) redis (5.3.0) redis-client (>= 0.22.0) redis-client (0.23.2) @@ -42,6 +44,7 @@ PLATFORMS DEPENDENCIES logster! puma + rackup redis sinatra From 2626e10c1d6d0399d9fe182b7ad7b936840a8a04 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 29 Apr 2026 16:49:47 -0400 Subject: [PATCH 2/8] bump version --- CHANGELOG.md | 95 ++---------------------------------------- lib/logster/version.rb | 2 +- 2 files changed, 4 insertions(+), 93 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af1497c0..4068526f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,156 +1,123 @@ # CHANGELOG -- 2025-02-06: 2.20.1 +- 2026-04-29: 2.21.0 + - FEATURE: Allow editing grouping pattern before submitting +- 2025-02-06: 2.20.1 - FIX: Don't break search when providing invalid regex characters - 2024-07-05: 2.20.0 - - Dropped support for Ruby 3.0 - Add `Logster::Logger#subscribe` which allows subscribing to log events from `Logster::Logger`. - 2024-03-12: 2.19.1 - - FIX: Don’t truncate backtrace on copying - 2024-02-28: 2.19.0 - - FIX: Add compatibility with Rails 7.1+ - 2024-02-19: 2.18.1 - - UX: backlink in dark mode has a dark background - 2024-02-15: 2.18.0 - - FEATURE: Implement a default Content-Security-Policy - 2024-02-15: 2.17.1 - - UX: fixed top menu when backlink to the site exists - 2024-02-15: 2.17.0 - - FEATURE: backlink to site - 2024-01-19: 2.16.0 - - FEATURE: Add inline grouping pattern creation - 2024-01-16: 2.15.0 - - FEATURE: Add loading spinner - 2024-01-15: 2.14.0 - - FEATURE: Stop grouping logs with different messages - 2023-11-01: 2.13.1 - - FIX: Solve/remove buttons on 'share' page - 2023-10-03: 2.13.0 - - FEATURE: Format messages with Logster::Logger#formatter before storing - 2023-03-10: 2.12.2 - - FIX: Don't throw on non-gem backtrace lines - 2023-03-10: 2.12.1 Note: 2.12.0 was yanked due to a release process error - - DEV: Upgrade to Ember 3.28 - 2023-01-30: 2.11.4 - - DEV: Various dependencies upgrade - FIX: Switch the `/messages.json` endpoint from `GET` to `POST` - 2022-08-25: 2.11.3 - - DEV: Avoid deprecation warning in Redis 4.8 (#166) - 2022-04-28: 2.11.2 - - FIX: store override level in thread local storage (Truffle Ruby compatibility) - 2022-04-21: 2.11.1 - - FIX: Redis pipelining deprecation (#159) - 2022-03-12: 2.11.0 - - FEATURE: Improve support for logging error objects (#153) - 2021-11-26: 2.10.1 - - UX: More dark-mode related changes - 2021-11-26: 2.10.0 - - FEATURE: Introduce dark mode - 2021-10-27: 2.9.8 - - FIX: We weren't properly memoizing the hostname - 2021-07-01: 2.9.7 - - FEATURE: Optionally use full hostname - 2021-02-19: 2.9.6 - - UX: Make `Warn` level visible by default - 2021-01-21: 2.9.5 - - FIX: Stop encoding errors when converting Message objects to JSON (#128) - DEV: Bump dependencies - 2020-09-01: 2.9.4 - - FEATURE: Merge messages differing only by numbers (#118) - DEV: Bump dependencies - UX: Turn severities below `Error` off by default and remember changes using localStorage (#125) - 2020-08-20: 2.9.3 - - FIX: fix code that causes warning from recent redis gem - 2020-08-11: 2.9.2 - - FIX: `report_js_error` incorrectly denying logs when Redis#exists returns integer - 2020-07-20: 2.9.1 - - FIX: Missing application backtrace in chained loggers. - 2020-06-11: 2.9.0 - - FEATURE: Allows JS errors to specify a log severity - DEV: Several dependencies upgrades - FIX: Don't search if the phrase hasn't changed - UX: Distinguish the value of the current env from the values of other envs in a merged message - 2020-03-30: 2.8.0 - - FEATURE: Upgrade icons to Font Awesome 5 - 2020-03-03: 2.7.1 - - FIX: Stop env mutation to allow all chained loggers to have the same env (#110) - 2020-02-26: 2.7.0 - - FEATURE: Make log message max length configurable and bump the default to 2000 (#109) - 2020-02-17: 2.6.3 - - FIX: Respect redis namespace when fetching env using LUA - 2020-02-09: 2.6.2 - - FIX: Regression with rendering single env when `env_expandable_keys` config is present - DEV: Fix Ember deprecations in tests - DEV: Add more tests to env rendering @@ -159,11 +126,9 @@ - FIX: Fetch env when navigating through grouped messages - 2020-02-07: 2.6.1 - - FIX: Fetch env when row is selected to allow copy to work on Firefox - 2020-02-07: 2.6.0 - - DEV: Bump handlebars from 4.1.2 to 4.5.3 in /client-app (#102) - FEATURE: Linkify backtrace lines to github (#104) - UX: Keep the 50 most recent envs rather than the first 50 (#103). Also introduces new config options `max_env_bytes` and `max_env_count_per_message`. @@ -172,7 +137,6 @@ - DEV: Upgrade Ember to 3.15 and remove jQuery and lodash as dependencies (#107) - 2019-12-13: 2.5.1 - - DEV: Bump puma from 4.2.1 to 4.3.1 in /website (#100) - FIX: Don't include messages that were removed from groups due to max size limit - FIX: loadingEnv is an attribute of model @@ -180,7 +144,6 @@ - UX: Group count attribute should be a long-running number of errors, not just the number of errors the group currently contains - 2019-12-12: 2.5.0 - - DEV: Update to latest version of gems - FIX: when rate limiting return an object responding to each - FEATURE: Expose the search phrase in query params @@ -188,11 +151,9 @@ - FEATURE: Custom grouping patterns - 2019-10-28: 2.4.2 - - FIX: wrong number of arguments when adding message using a block (#98) - 2019-10-17: 2.4.1 - - PERF: Debounce search field so it doesn't fire a search query at every keystroke. - PERF: Disallow search terms that are fewer than 2 characters long. - PERF: Bypass refresh cycle if previous cycle hasn't finished. @@ -200,63 +161,50 @@ - PERF: Cap message size to 60,000 bytes by default. - 2019-10-10: 2.4.0 - - FEATURE: Allow having retroactive affect when adding suppression patterns - DEV: Bump JS dependencies - 2019-10-08: 2.3.3 - - FEATURE: keep track of message timestamp when it's merged into another message - 2019-08-20: 2.3.2 - - FEATURE: automatic 1 minute rate limiting for js error reporting per IP - 2019-08-15: 2.3.1 - - DEV: upgrade Ember to 3.8 and jQuery to 3.4.1 (#84) - FIX: properly escape string ignore pattern (#88) - FIX: scrub params if they have invalid encoding (#92) - 2019-03-26: 2.3.0 - - FEATURE: track count of suppressed logs for each pattern - 2019-03-19: 2.2.0 - - FEATURE: custom suppression patterns via UI - UX: auto expand env keys when list length is <= 3 - 2019-03-14: Unreleased - - FIX: Logster message options missing when base logger is a sub-class of `Logster::Logger` - 2019-02-21: Version 2.1.2 - - FEATURE: allow certain env keys to be expandable via `Logster.config.env_expandable_keys.push(:key, :another_key)`. See https://github.com/discourse/logster/pull/81 for more info - 2019-02-21: Version 2.1.1 - - FEATURE: allow defer logger to be disabled as Ruby 2.5.3 can segfault with defer logger due to a bug in Ruby. To disable run `Logster::Scheduler.disable` - 2019-02-13: Version 2.1.0 - - FEATURE/DEV: adds a defer logger that will do logging asynchronously only in dev environments. It should speed things up a little in dev. - 2019-02-05: Version 2.0.1 - - FIX: env line height issue on iOS - 2019-01-17: Version 2.0.0.pre - - FIX: don't merge any new env samples if there are 50 samples (1.4.0.pre regression) - UX: make env navigation controls stick to the top when scrolled - PERF: store env samples separately from the rest of message data - DEV: Rubocop - 2019-01-09: Version 1.4.0.pre - - FEATURE: allow navigation through merged errors - FEATURE: search should look at env - FIX: deselect message if new filtering doesn't include selected message @@ -264,85 +212,67 @@ - FIX: hide "load more" when there are no more messages and filters/search applied - 2018-12-30: Version 1.3.4 - - FIX: linear-gradient issue on iOS - FIX: actions menu should have highest z-index - 2018-12-26: Version 1.3.3 - - Fix: fix double lines logs when date is too long - 2018-12-25: Version 1.3.2 - - UX: improve usability on mobile - 2018-11-09: Version 1.3.1 - - Feature: auto scrub invalid messages reported to logger - 2018-11-09: Version 1.3.0 - - Feature: upgrade Ember to 3.5.1 - Feature: remove inline JS for CSP compliance - 2018-08-13: Version 1.2.10 - - Feature: expose chained loggers in Logster::Logger - 2017-10-27: Version 1.2.8 - - Fix: `Logster::Middleware::DebugExceptions` is passed a request in Rails 5 instead of the env. - 2017-01-30: Version 1.2.7 - - Feature: Add override_level to Logster::Logger allowing for threadsafe logger override - 2016-10-24: Version 1.2.6 - - Fix: Check if `Rails.env` is defined when using Logster in a none Rails project. - 2016-07-11: Version 1.2.5 - - Fix: Chained `Logster::Logger` logger now receives backtrace as well. - 2016-05-05: Version 1.2.4 - - Fix: XSS in log message show if attacker can inject script into ENV - 2016-05-05: Version 1.2.3 - - Fix: clear_all now also clears rate limits - Fix: protect against corrupt data in redis during clear - 2016-03-22: Version 1.2.2 - - Fix: Conflicting attributes and method name for `Logster::RedisStore#rate_limits`. - Fix: Rate limit checker was tracking limits too early. It should only track when a message has been bumped or saved. - 2016-03-22: Version 1.2.1 - - Feature: Add method to retrieve current rate from rate limiters. - Feature: Make `RedisStore#rate_limits` readable. - Feature: Make `RedisRateLimiter#callback` and `RedisRateLimiter#duration` readable. - 2016-03-18: Version 1.2.0 - - Fix: Move Redis configuration into RedisStore. - Feature: Allow `RedisStore#redis_prefix` to either be a String or a Proc. - 2016-02-11: Version 1.1.1 - - Feature: Error rate can now be tracked in one minute and one hour buckets. - 2015-11-27: Version 1.0.1 - - New assets and logster logo - Added favicon - Added title - Use rails logger instead of invoking store - 2015-08-18: Version 0.9.9 - - This marks the largest release of Logster to date, it has been in production use for quite a while, hence the version bump. - Feature: automatically group errors in production mode, can be manually controlled via Logster.config.allow_grouping - Feature: automatically track application version, can be manually controlled via Logster.config.application_version @@ -359,46 +289,36 @@ - Fix: protect/unprotect redirected to show page - 2015-06-16: Version 0.8.3 - - Chained loggers now respect chain ignore - Add hostname and process_id to env on all messages - 2015-06-10: Version 0.8.2 - - Add hostname and process_id to env on all messages - 2015-05-01: Version 0.8.1 - - Don't crash out logging routine if redis is down or stderr is closed - 2015-04-16: Version 0.8.0 - - Improve formatting of /show page - Big version bump cause it is quite stable - 2015-02-27: Version 0.1.7 - - Fix invalid request on ?test - 2014-08-05: Version 0.1.3 - - Automatically include ignore filter - 2014-08-13: Version 0.1.6 - - Simplify install process - Fix crash on 404 in /logs dir - 2014-08-10: Version 0.1.5 - - Fix crash in Rails 3 - 2014-08-08: Version 0.1.4 - - Fix crash in ignore filter - 2014-07-17: Version 0.1.1 - - Refactored report method into base_store.rb - will be easier to make a new log store - Add link in UI to clear all (non-protected) logs - Add example of submitting logs from Sidekiq jobs @@ -406,42 +326,33 @@ - Render hashes provided via Logster.add_to_env - 2014-07-04: Version 0.0.12 - - Feature: Able to share logs, at /logs/show/(hexdigits) - Add protecting logs, so they aren't deleted when old (for use with sharing) - Restructured Redis data model - 2014-05-24: Version 0.0.10 - - Correct context for error reporting - Clean up backtraces of reported exceptions - 2014-05-13: Version 0.0.9 - - Stray debugger message removed, add window.location logging to js - 2014-05-13: Version 0.0.8 - - Fix packaging binstubs by mistake - 2014-05-13: Version 0.0.7 - - Add support for javascript exception logging - 2014-05-12: Version 0.0.6 - - Add referer to env - 2014-05-12: Version 0.0.5 - - Feature: We now log basic rack environment with the messages - Add your own with Logster.add_to_env(env, key, value) - 2014-05-07: Version 0.0.4 - - Feature: Ability to ignore patterns with Logster.store.ignore = [/regex/] - Feature: Store backtraces, allow people to view them in the GUI - 2014-05-07: Started changelog :) - - Report params in env tab diff --git a/lib/logster/version.rb b/lib/logster/version.rb index 0e97d5bf..2dd4c8d4 100644 --- a/lib/logster/version.rb +++ b/lib/logster/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Logster - VERSION = "2.20.1" + VERSION = "2.21.0" end From d471bcdbcaf3e947caa4528a93f63e0d64466cf3 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 29 Apr 2026 17:03:13 -0400 Subject: [PATCH 3/8] lint --- lib/logster/middleware/viewer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logster/middleware/viewer.rb b/lib/logster/middleware/viewer.rb index 1caed4d7..71acc10e 100644 --- a/lib/logster/middleware/viewer.rb +++ b/lib/logster/middleware/viewer.rb @@ -118,7 +118,7 @@ def call(env) end elsif resource =~ %r{/patterns/([a-zA-Z0-9_]+)\.json$} unless Logster.config.enable_custom_patterns_via_ui - return( + return ( not_allowed( "Custom patterns via the UI is disabled. You can enable it by committing this line to your app source code:\nLogster.config.enable_custom_patterns_via_ui = true", ) From ab6a0e1edb3e00e38a09dc45c526d3627759bf2f Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 29 Apr 2026 17:07:25 -0400 Subject: [PATCH 4/8] disable Layout/SpaceAroundKeyword in rubocop, it is covered by stree --- .rubocop.yml | 2 ++ lib/logster/middleware/viewer.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1ff05e0a..862f3c7f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,3 +8,5 @@ AllCops: - 'client-app/**/*' Discourse/Plugins/NamespaceConstants: Enabled: false +Layout/SpaceAroundKeyword: + Enabled: false diff --git a/lib/logster/middleware/viewer.rb b/lib/logster/middleware/viewer.rb index 71acc10e..1caed4d7 100644 --- a/lib/logster/middleware/viewer.rb +++ b/lib/logster/middleware/viewer.rb @@ -118,7 +118,7 @@ def call(env) end elsif resource =~ %r{/patterns/([a-zA-Z0-9_]+)\.json$} unless Logster.config.enable_custom_patterns_via_ui - return ( + return( not_allowed( "Custom patterns via the UI is disabled. You can enable it by committing this line to your app source code:\nLogster.config.enable_custom_patterns_via_ui = true", ) From 90cc1674eaad941fa1befdda4b39f3367aba558c Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Thu, 30 Apr 2026 09:17:36 -0400 Subject: [PATCH 5/8] Remove rackup --- Rakefile | 5 +---- website/Gemfile | 11 +++++------ website/Gemfile.lock | 5 +---- website/README.md | 2 +- website/sample.rb | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Rakefile b/Rakefile index ed5b0728..960f3727 100644 --- a/Rakefile +++ b/Rakefile @@ -12,10 +12,7 @@ task(default: :test) desc "Starts Sinatra and Ember servers" task :client_dev do begin - pid = - spawn( - "cd website && LOGSTER_ENV=development BUNDLE_GEMFILE=Gemfile bundle exec rackup --host 0.0.0.0", - ) + pid = spawn("cd website && LOGSTER_ENV=development BUNDLE_GEMFILE=Gemfile bundle exec puma") pid2 = spawn("cd client-app && npx ember s --proxy http://localhost:9292") Process.wait pid Process.wait pid2 diff --git a/website/Gemfile b/website/Gemfile index 5146353f..8320edfb 100644 --- a/website/Gemfile +++ b/website/Gemfile @@ -1,9 +1,8 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" -gem 'sinatra' -gem 'redis' -gem 'logster', path: '../' -gem 'puma' -gem 'rackup' +gem "sinatra" +gem "redis" +gem "logster", path: "../" +gem "puma" diff --git a/website/Gemfile.lock b/website/Gemfile.lock index fc9dcaae..67bc619f 100644 --- a/website/Gemfile.lock +++ b/website/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - logster (2.20.1) + logster (2.21.0) GEM remote: https://rubygems.org/ @@ -22,8 +22,6 @@ GEM rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) - rackup (2.3.1) - rack (>= 3) redis (5.3.0) redis-client (>= 0.22.0) redis-client (0.23.2) @@ -44,7 +42,6 @@ PLATFORMS DEPENDENCIES logster! puma - rackup redis sinatra diff --git a/website/README.md b/website/README.md index 177afa23..fff6f3d6 100644 --- a/website/README.md +++ b/website/README.md @@ -6,5 +6,5 @@ To start it and test your code changes: ```text $ bundle install -$ bundle exec rackup +$ bundle exec puma ``` diff --git a/website/sample.rb b/website/sample.rb index 99e80be5..927cbde7 100644 --- a/website/sample.rb +++ b/website/sample.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# Run with 'bundle exec rackup' +# Run with 'bundle exec puma' require "redis" require "logster" From 42063be028aa8a7dffbd24795a55d3ee533a29a5 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Thu, 30 Apr 2026 09:33:58 -0400 Subject: [PATCH 6/8] fix linting run, test run --- Gemfile | 1 + lib/logster/group.rb | 4 ++-- lib/logster/message.rb | 8 ++++---- lib/logster/middleware/viewer.rb | 2 +- test/examples/test_sidekiq_reporter_example.rb | 2 +- test/logster/test_group.rb | 2 +- test/logster/test_message.rb | 2 +- test/test_helper.rb | 16 +++++++++++++++- website/sample.rb | 2 +- 9 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 177c53bc..acfa9b76 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,5 @@ gemspec group :development, :test do gem "rails", ">= 6.1" + gem "rubocop-capybara", "< 2.23.0" end diff --git a/lib/logster/group.rb b/lib/logster/group.rb index 0ba67ef8..179eff65 100644 --- a/lib/logster/group.rb +++ b/lib/logster/group.rb @@ -48,7 +48,7 @@ def to_h_web end def to_json(opts = nil) - JSON.fast_generate(self.to_h, opts) + JSON.generate(self.to_h, opts) end def add_message(message) @@ -109,7 +109,7 @@ def max_size GroupWeb = Struct.new(*%i[regex count timestamp messages row_id]) do def to_json(opts = nil) - JSON.fast_generate(self.to_h.merge(severity: -1, group: true), opts) + JSON.generate(self.to_h.merge(severity: -1, group: true), opts) end def key diff --git a/lib/logster/message.rb b/lib/logster/message.rb index f530fdef..3daceb5c 100644 --- a/lib/logster/message.rb +++ b/lib/logster/message.rb @@ -65,7 +65,7 @@ def to_h(exclude_env: false) def to_json(opts = nil) exclude_env = Hash === opts && opts.delete(:exclude_env) - JSON.fast_generate(to_h(exclude_env: exclude_env), opts) + JSON.generate(to_h(exclude_env: exclude_env), opts) end def self.from_json(json) @@ -134,7 +134,7 @@ def grouping_hash # todo - memoize? def grouping_key - Digest::SHA1.hexdigest JSON.fast_generate grouping_hash + Digest::SHA1.hexdigest JSON.generate grouping_hash end # todo - memoize? @@ -273,10 +273,10 @@ def truncate_backtrace(bytes_limit) protected def truncate_env(env, limit) - if JSON.fast_generate(env).bytesize > limit + if JSON.generate(env).bytesize > limit sizes = {} braces = "{}".bytesize - env.each { |k, v| sizes[k] = JSON.fast_generate(k => v).bytesize - braces } + env.each { |k, v| sizes[k] = JSON.generate(k => v).bytesize - braces } sorted = env.keys.sort { |a, b| sizes[a] <=> sizes[b] } kept_keys = [] diff --git a/lib/logster/middleware/viewer.rb b/lib/logster/middleware/viewer.rb index 1caed4d7..516118ba 100644 --- a/lib/logster/middleware/viewer.rb +++ b/lib/logster/middleware/viewer.rb @@ -308,7 +308,7 @@ def script(name, csp_nonce) end def to_json_and_escape(payload) - Rack::Utils.escape_html(JSON.fast_generate(payload)) + Rack::Utils.escape_html(JSON.generate(payload)) end def preload_backtrace_data diff --git a/test/examples/test_sidekiq_reporter_example.rb b/test/examples/test_sidekiq_reporter_example.rb index 5c84f368..d703d7f6 100644 --- a/test/examples/test_sidekiq_reporter_example.rb +++ b/test/examples/test_sidekiq_reporter_example.rb @@ -6,7 +6,7 @@ require "logger" require "examples/sidekiq_logster_reporter" -class TestSidekiqReporter < MiniTest::Test +class TestSidekiqReporter < Minitest::Test def setup Logster.store = @store = Logster::RedisStore.new(Redis.new) Logster.logger = @logger = Logster::Logger.new(Logster.store) diff --git a/test/logster/test_group.rb b/test/logster/test_group.rb index e5b62084..ecdae4ad 100644 --- a/test/logster/test_group.rb +++ b/test/logster/test_group.rb @@ -4,7 +4,7 @@ require "logster/group" require "logster/message" -class TestGroup < MiniTest::Test +class TestGroup < Minitest::Test def test_changed_is_true_for_new_instances assert Logster::Group.new("/somekey/").changed? end diff --git a/test/logster/test_message.rb b/test/logster/test_message.rb index 85138c4f..21bd7cf3 100644 --- a/test/logster/test_message.rb +++ b/test/logster/test_message.rb @@ -3,7 +3,7 @@ require_relative "../test_helper" require "logster/message" -class TestMessage < MiniTest::Test +class TestMessage < Minitest::Test def test_merge_similar msg1 = Logster::Message.new(0, "", "test", 10) msg1.populate_from_env(a: "1", b: "2") diff --git a/test/test_helper.rb b/test/test_helper.rb index a647b7a6..a36ecefe 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,9 +1,23 @@ # frozen_string_literal: true require "minitest" -require "minitest/unit" require "minitest/autorun" require "minitest/pride" + +module StubSupport + def stub(method_name, value_or_callable = nil, &block) + original = method(method_name) + define_singleton_method(method_name) do |*args, &blk| + value_or_callable.respond_to?(:call) ? value_or_callable.call(*args, &blk) : value_or_callable + end + yield self + ensure + singleton_class.undef_method(method_name) rescue nil + define_singleton_method(method_name, original) rescue nil + end +end + +Module.include StubSupport require "redis" require "logster" require "logster/base_store" diff --git a/website/sample.rb b/website/sample.rb index 927cbde7..c60e98d3 100644 --- a/website/sample.rb +++ b/website/sample.rb @@ -25,7 +25,7 @@ def ensure_samples_loaded SAMPLE_REDIS.del @sample_data_key data = File.read("data/data.json") parsed = JSON.parse(data) - parsed.each { |row| SAMPLE_REDIS.rpush @sample_data_key, JSON.fast_generate(row) } + parsed.each { |row| SAMPLE_REDIS.rpush @sample_data_key, JSON.generate(row) } @length = parsed.length end From 7a78d444ea5d15596d12f2dee183743d0bc50e19 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Thu, 30 Apr 2026 09:35:52 -0400 Subject: [PATCH 7/8] stree --- test/test_helper.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index a36ecefe..63373db8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -12,8 +12,16 @@ def stub(method_name, value_or_callable = nil, &block) end yield self ensure - singleton_class.undef_method(method_name) rescue nil - define_singleton_method(method_name, original) rescue nil + begin + singleton_class.undef_method(method_name) + rescue StandardError + nil + end + begin + define_singleton_method(method_name, original) + rescue StandardError + nil + end end end From ff605df7ca7e001b8502bb3f80a69c6c0589227b Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Thu, 30 Apr 2026 10:36:13 -0400 Subject: [PATCH 8/8] capybara issue solved upstream --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index acfa9b76..177c53bc 100644 --- a/Gemfile +++ b/Gemfile @@ -7,5 +7,4 @@ gemspec group :development, :test do gem "rails", ">= 6.1" - gem "rubocop-capybara", "< 2.23.0" end