Fix TaggedLogging to allow loggers to be instantiated multiple times without having to share the stack of tags#9065
Conversation
…without having to share the stack of tags. This is accomplished by using a unique key for the thread-local tag list. Fixes rails#9064.
|
Looks good. Having a thread-local formatter might feel nicer, but it's a hassle to implement. /cc @tenderlove |
|
Don't we have Thread local configs now, that could be used for it? |
|
@carlosantoniodasilva: The tagged logger already uses a thread-local. The problem is that it acts as if there can only be a single tagged logger instance. Here's my example from the previous issue (sorry about the dupe, didn't know Github listed pull requests in the issue tracker): It's also not safe to wrap a unique logger (ie., one that does not delegate to a logger shared around in the app, like In other words, The fix uses a unique key to store the thread-local tag list. (The only weakness is that the thread-local key will never be garbage collected until the thread dies, but it seems unrealistic that anyone would create a huge number of loggers.) |
|
👍 I wanted this behavior and expected it to just work. Particularly because |
Fix TaggedLogging to allow loggers to be instantiated multiple times without having to share the stack of tags
|
@rafaelfranca Was this change ever released? Looks like it's not included in ActiveSupport 4.2. |
|
@stephankaag: No, for some reason it's still only on |
Add #9065 to CHANGELOG [ci skip]
This is accomplished by using a unique key for the thread-local tag list. Fixes #9064.