More compatibility with ActiveSupport Logger broadcast usage #967
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#935 allows the usage of
ActiveSupport::Logger.broadcast
. There still seems to be an issue when using the convenience methods from logger.Logger.warn("Something happened")
won't show up in AppSignal.(There already is a detailed description what happens when adding a broadcast in #930.)
A new Rails App would create an ActiveSupport Logger in production if logging to the console is requested (which a Twelve-Factor App would do).
config/environments/production.rb
:I want to keep the console output and broadcast to an AppSignal logger:
At first glance this seems to work. All requests are logged in AppSignal. But using the convenience methods would log to the console but not to AppSignal.
This is because the convenience methods are calling
add
with the log message in the third argument. ButAppsignal::Logger#add
won't take the message fromgroup
as a fallback ifmessage
isnil
. It looks like you forgot to renameprogname
togroup
as well:appsignal-ruby/lib/appsignal/logger.rb
Line 46 in 05dc9fe
After the fixes in this PR
Rails.logger.warn("Something happened")
works for me as expected.