Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the logdev #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Expose the logdev #88

wants to merge 1 commit into from

Conversation

oggy
Copy link

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant