[ruby-core:94892] [Ruby master Feature#16144] Honor Logger#level overrides in Logger#add
From:
georgeclaghorn@...
Date:
2019-09-10 17:42:13 UTC
List:
ruby-core #94892
Issue #16144 has been updated by georgeclaghorn (George Claghorn). My GitHub PR was merged, so I think this can be closed. ---------------------------------------- Feature #16144: Honor Logger#level overrides in Logger#add https://bugs.ruby-lang.org/issues/16144#change-81506 * Author: georgeclaghorn (George Claghorn) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- We attempt to override `Logger#level` in Rails’s `Logger` subclass to [allow setting a different level per thread](https://github.com/rails/rails/blob/d03d6fc33b4e9629e3e969c18bda4bdcd3c01c90/activesupport/lib/active_support/logger_thread_safe_level.rb) (and thus per request). But `Logger#add` checks the new message’s severity against the `@level` instance variable, so overriding `#level` doesn’t have the intended effect. (Because we prepend a check against `#level` to `#add`, you can only set the thread-local level greater than or equal to `@level`, not less. We’d like to allow setting any thread-local level.) This patch modifies `Logger#add` to check `#level` so that third-party loggers can customize how the current level is determined without needing to reimplement `#add` or juggle multiple underlying `Logger` instances. This is my first Ruby patch. I wasn’t sure whether to submit it here or [ruby/logger](https://github.com/ruby/logger) on GitHub. I’m sorry if this isn’t the right place. ---Files-------------------------------- 0001-Honor-Logger-level-overrides-in-Logger-add.patch (2.53 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>