logger
logger copied to clipboard
Use ObjectSpace::WeakKeyMap for level_override
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 abandoned without running their ensure blocks.
Please note that Thread#kill is not the only way for a Fiber to be abandoned without running its ensure block. It's as simple as to_enum(:method_that_calls_with_level).next.
This is related to @byroot's comment here: https://github.com/ruby/logger/pull/132#discussion_r2393892976