Skip to content

Conversation

nevans
Copy link

@nevans nevans commented Oct 1, 2025

Cloning loggers can be used, for example, to create different loggers for different classes/components/subsystems that share the same log_dev and other configuration (possibly a subclass of Logger), but with different verbosity levels, formatters, etc.

But, that can break if they share @level_override. Rather than use OverrideMap.new, the existing @level_override is cloned and cleared, to preserve @level_override's class.


This PR is based on #136 to avoid merge conflicts. But it can be updated to be independent of that other PR, if so desired.

nevans added 2 commits October 1, 2025 12:16
This allows fiber keys to be GCed and removed from the map.  Otherwise,
fibers that call `#with_level` create a memory leak if they are killed
without running their ensure blocks.
Cloning loggers can be used, for example, to create different loggers
for different classes/components/subsystems that share the same log_dev
and other configuration (possibly a subclass of Logger), but with
different verbosity levels, formatters, etc.

But, that doesn't work if they share `@level_override`.  Rather than
use OverrideMap.new, the existing `@level_override` is cloned and
cleared, to preserve `@level_override`'s class.
@nevans nevans force-pushed the clone-resets-logger_override branch from 5f37f2b to 1b4e472 Compare October 1, 2025 17:05
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.

1 participant