We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I ran into #48 and from what I can tell, formatters would not work when passing in the Rails.logger. Suppose we have this:
Rails.logger
use GrapeLogging::Middleware::RequestLogger, { logger: Rails.logger, formatter: GrapeLogging::Formatters::Json.new }
It looks like log reporter would attempt to set the Rails.logger formatter globally
class LoggerReporter def initialize(logger, formatter, log_level) @logger = logger || Logger.new(STDOUT) @log_level = log_level || :info if @logger.respond_to?(:formatter=) @logger.formatter = formatter || @logger.formatter || GrapeLogging::Formatters::Default.new end end
This won't work because Rails assumes the formatter is of type ActiveSupport::TaggedLogging::Formatter and we get the error mentioned in #48.
undefined method `clear_tags!
Either way I am not sure we would actually want to set the GrapeLogging Formatter globally on the Rails.logger as this seems a bit heavy handed.
To get around this issue, I used the instrumentation_key feature and avoid using Rails.logger and GrapeLogging formatters altogether.
use GrapeLogging::Middleware::RequestLogger, { instrumentation_key: 'grape_logging', include: [GrapeLogging::Loggers::FilterParameters.new] } ActiveSupport::Notifications.subscribe('grape_logging') do |_name, _starts, _ends, _notification_id, payload| Rails.logger.info("API request #{payload.to_json}") end
This is fine for my purposes but I am not sure of the right way to use grape log formatters and Rails.logger together.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I ran into #48 and from what I can tell, formatters would not work when passing in the
Rails.logger
. Suppose we have this:It looks like log reporter would attempt to set the Rails.logger formatter globally
This won't work because Rails assumes the formatter is of type ActiveSupport::TaggedLogging::Formatter and we get the error mentioned in #48.
Either way I am not sure we would actually want to set the GrapeLogging Formatter globally on the
Rails.logger
as this seems a bit heavy handed.To get around this issue, I used the instrumentation_key feature and avoid using Rails.logger and GrapeLogging formatters altogether.
This is fine for my purposes but I am not sure of the right way to use grape log formatters and Rails.logger together.
The text was updated successfully, but these errors were encountered: