Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Console::Filter[...] threw uninitialized constant DEFAULT_LEVEL and couldn't chain with loggers having different severity levels.

Changes

  • Added DEFAULT_LEVEL constant to dynamically created filter classes (set to MINIMUM_LEVEL)
  • Modified call() to pass through unknown severities without filtering, enabling filter composition

Example

# Now works - previously threw NameError
MyLogger = Console::Filter[noise: 0, stuff: 1, broken: 2]
logger = MyLogger.new(Console.logger, name: "Java", verbose: true)
logger.broken("It's so janky.")  # ✓ passes :broken through to Console.logger

Unknown severities pass through to support chaining filters with disjoint severity sets.

Original prompt

This section details on the original issue you should resolve

<issue_title>Console::Filter seem to be broken</issue_title>
<issue_description>Given the filter example:

require "console"

MyLogger = Console::Filter[noise: 0, stuff: 1, broken: 2]

# verbose: true - log severity/name/pid etc.
logger = MyLogger.new(Console.logger, name: "Java", verbose: true)

logger.broken("It's so janky.")

Running it results in:

/home/roadster/.gem/ruby/4.0.1/gems/console-1.34.2/lib/console/filter.rb:81:in 'Console::Filter#initialize': uninitialized constant MyLogger::DEFAULT_LEVEL (NameError)

                                @level = self.class::DEFAULT_LEVEL
                                                   ^^^^^^^^^^^^^^^
        from console_test.rb:6:in '<main>'
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@ioquatix</author><body>
Dude, it's so janky, who wrote this broken code!? :p</body></comment_new>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 11, 2026 21:02
…ties

- Add DEFAULT_LEVEL constant when creating dynamic filter classes via Filter[]
- Make call() method handle nil level (unknown severity) by passing through
- Add tests for custom filter creation and chained loggers
- Fixes issue where Filter[...].new() would fail with uninitialized constant error

Co-authored-by: ioquatix <30030+ioquatix@users.noreply.github.com>
- Document DEFAULT_LEVEL constant and its relationship to MINIMUM_LEVEL
- Clarify behavior when call() receives unknown severities
- Explain that unknown severities pass through to support filter composition

Co-authored-by: ioquatix <30030+ioquatix@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix broken Console::Filter initialization Fix Console::Filter dynamic class creation and severity chaining Feb 11, 2026
Copilot AI requested a review from ioquatix February 11, 2026 21:06
Copy link
Member

@ioquatix ioquatix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM LFG

@ioquatix ioquatix marked this pull request as ready for review February 11, 2026 21:49
@ioquatix ioquatix merged commit f63c100 into main Feb 11, 2026
34 of 40 checks passed
@ioquatix ioquatix deleted the copilot/fix-console-filter-issue branch February 11, 2026 23:38
@ioquatix ioquatix added this to the v1.34.3 milestone Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console::Filter seem to be broken

2 participants