Allow for replacing padrino's logger with our own #2118

Closed
cburgmer opened this Issue Jan 20, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@cburgmer

We want to modify the padrino logging output. The only viable way we found was to replace the default logger with our own instance:

logger = Logger.new('log/production.log')
logger.formatter = proc do |s, d, p, m|
   ...
end
Padrino.logger = logger

However, we are logging objects, not just strings. Just that they never arrive intact when the formatter is called. They just magically get turned into strings again. Turns out this line is responsible for that: https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/logger.rb#L78.

Why are we even triggering this code, if we have replaced the default logger? Turns out this line is doing this: https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/logger.rb#L316.

Our current work around:

# Monkey patch the Logger to ignore the monkey patching on padrino's side
class Logger
  def extend(*args)
  end
  def devel(*args)
  end
  def exception(boom, *args)
    error(boom.message)
  end
end

Long story short: Please allow us to side-step this behaviour of Padrino, or at least allow us to log our arbitrary logging format. Human readable format is not cutting it for us, we want machines to understand.

@ujifgc ujifgc added the enhancement label Jan 20, 2017

@ujifgc ujifgc closed this in 8440eac Mar 21, 2017

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Mar 21, 2017

Member

Thank you for your report, fixed in 8440eac

Member

ujifgc commented Mar 21, 2017

Thank you for your report, fixed in 8440eac

adam12 added a commit to adam12/padrino-framework that referenced this issue Jun 5, 2017

allow Logger without Extensions, fixes #2118
WARNING: this changes behavior of `Padrino.logger = new_logger` and adds a deprecation warning about this advanced use.

This does not change the default behavior of Padrino::Logger.setup!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment