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

✨ Support Alternate Loggers #22

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

pboling
Copy link
Contributor

@pboling pboling commented Nov 21, 2024

Since Rails uses autoloading, there is no need to explicitly require active_support/tagged_logging, and doing so actively prevents using an alternative.

I have created a suite of gems that replace the Rails logger. They extract the logging tooling from Rails 8, add in some refactoring and fixes that allow broadcasting, tagged logging, and blocks, to all work together, (which bugs have always been present in tagged logging, and remain in v8.0, see Rails PR 53093 and Rails PR 53105).

It works with Rails because of the autoloading. If a namespace / constant is already defined, it won't go looking for it. So by defining it in my extracted gems, the vanilla (broken) Rails version doesn't load.

At that point the only problem comes from libraries which load certain Rails internals explicitly.

The suite of gems I'm aiming to have compatibility with is:

@santry santry merged commit 2b73820 into santry:main Nov 21, 2024
16 checks passed
@santry
Copy link
Owner

santry commented Nov 21, 2024

Thanks @pboling!

@pboling pboling deleted the support-alternative-loggers branch November 21, 2024 19:42
@pboling
Copy link
Contributor Author

pboling commented Nov 21, 2024

Thanks! This was a good change, as, specifically TaggedLogging is one of the things Rails auto-loads...

But now I've discovered there are a few things that Rails loads explicitly, within active_support, that I'll need to work around. I was doing that in v1 of the suite, but didn't think I'd need to anymore, and I was wrong.

Anyways, this helps me get where I am going. Thanks again!

@pboling
Copy link
Contributor Author

pboling commented Nov 23, 2024

Also, FWIW, this is related:
soutaro/steep#484

which mentions that active_support must be explicitly required according to: https://guides.rubyonrails.org/active_support_core_extensions.html

and which took the same approach of stopping the explicit require of active_support/tagged_logging, just like we did here.

So this was the right approach, and may have preemptively fixed the same bug that the steep project saw.

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