aserafin / grape_logging

Request logging for Grape!
MIT License
147 stars 76 forks source link

Fix already configured logger formatter override #36

Closed e1senh0rn closed 7 years ago

e1senh0rn commented 7 years ago

I did discover slight inconsistency with logger configuration introduced in #23. If you have preconfigured logger with formatter, grape_logger will override it.

Here is an example.


class App < Grape::API

  log_handler = ::Logger.new(STDOUT)
  log_handler.formatter = GrapeLogging::Formatters::Json.new

  use GrapeLogging::Middleware::RequestLogger, logger: log_handler

  get "/" { status 200 }
end

If you perform request to such an app, it will use GrapeLogging::Formatters::Default because of check in LoggerReporter.

aserafin commented 7 years ago

@e1senh0rn good catch - thank you!