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

Already on GitHub? Sign in to your account

clean up remaining log flushing support #13651

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

cainlevy commented Jan 9, 2014

Currently, ActiveSupport::TaggedLogging#flush will clear out any tags before trying to call flush on the wrapped Logger, which no longer happens. The tag clearing logic appears to have been intentional when it was originally committed but we have been unable to imagine the use case.

This seems like an odd coupling. The coupled behaviors (clearing tags + flushing buffered logging to file) no longer appear to benefit Rails' own code, but can cause bugs when other code attempts to use Rails.logger.tagged{...}.

Rails' Code

The only place where I can find Rails calling #flush is via ActiveSupport::LogSubscriber.flush_all!. And the only place where I can find Rails calling that is from Rails::Rack::Logger#call_app.

In this case, the #flush logic is redundant because the next operation after #call_app - when tags are in use - is to pop the request's tags back off the stack. That ends up being a noop because the stack was just emptied.

Our Bug

I added a tag to our Delayed::Job workers so I could associate output with specific processes. I noticed that the tag was disappearing shortly after the process started, and eventually tracked it down to a particular job using the urbanairship gem, which still flushes after logging.

The Cleanup

Minimally, I would like to remove ActiveSupport::TaggedLogging#flush.

But at that point, I think there is no remaining logger that will respond_to?(:flush), which means that ActiveSupport::LogSubscriber#flush_all! is no longer effective and can also be removed. So I've cleaned up all the tendrils.

cainlevy added some commits Jan 9, 2014

keep logger tags on flush
clearing tags on flush is an oddly coupled side effect, and flushing
isn't really even used by current code.
Owner

jeremy commented Jun 12, 2014

Agree that clearing tags on flush doesn't (and didn't) make sense.

Removing #flush calls entirely is probably premature. Folks may still set Rails.logger to a logger that expects to be flushed, so that expectation would need to be properly deprecated.

Contributor

cainlevy commented Jun 13, 2014

thanks @jeremy. should i add the deprecation? if that's a bigger decision, i'm happy to just update the tagging behavior.

Member

sgrif commented Oct 29, 2015

Closing due to inactivity. As mentioned, removing #flush is probably premature.

@sgrif sgrif closed this Oct 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment