Skip to content

Conversation

oggy
Copy link
Contributor

@oggy oggy commented Mar 22, 2023

The motivation here is to fix a Rails issue caused by the way ActiveSupport extends the ruby Logger to add broadcasting of messages to multiple destinations. I believe the problem could be much more elegantly solved if Logger exposed the underlying LogDevice. Going by repo history, the existence of this object hasn't changed since 2003, so I think it's stable enough to expose.

In addition to letting you read the logdev, this also lets you pass a logdev in. To implement broadcasting, we could now define a LogDevice subclass that delegates its 3 methods to the LogDevices of a list of underlying loggers, and simply create a new logger with this device.

What do you think?

The motivation here is to fix a Rails issue caused by the way
ActiveSupport extends the ruby Logger to add broadcasting of messages to
multiple destinations. [1] I believe the problem could be much more
elegantly solved if Logger exposed the underlying LogDevice. Going by
repo history, the existence of this object hasn't changed since 2003, so
I think it's stable enough to expose.

In addition to letting you read the logdev, this also lets you pass a
logdev in. To implement broadcasting, we could now define a LogDevice
subclass that delegates its 3 methods to the LogDevices of a list of
underlying loggers, and simply create a new logger with this device.

[1]: https://github.com/rails/rails/blob/ba19dbc49956a73f417abd68c7a5f33e302eacd3/activesupport/lib/active_support/logger.rb#L23
@nobu nobu merged commit f9388e5 into ruby:master Jul 18, 2025
31 checks passed
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.

2 participants