multi_logger icon indicating copy to clipboard operation
multi_logger copied to clipboard

Logger handles '-' in filename by replacing it with '_'

Open davidchua opened this issue 10 years ago • 2 comments

When attempting to create a logger name 'omniauth-failure' in my config/initializer/logger.rb like:

MultiLogger.add_logger('omniauth-failure')

and then adding a logging command in my controller like:

def some_action
  logger.omniauth-failure.debug('error logged')
end

I'll get a NoMethodError when accessing the action.

NoMethodError (undefined method 'omniauth' for #<ActiveSupport::Logger:...........

A further investigation in my log/ directory shows that a file 'omniauth_failure.log' was created instead of 'omniauth-failure.log'.

davidchua avatar Mar 18 '14 02:03 davidchua

Since in Ruby you can't have dash/minus sign in method name, you can't access it. (I guess you can do a logger.send(:'omniauth-failure')). I guess I'll raise some warning. Meanwhile you can just switch to underscore naming.

lulalala avatar Mar 18 '14 08:03 lulalala

Thanks! That certainly would work.

Just thought I raise this issue up as well in case others experience the same thing and wonder what went wrong.

davidchua avatar Mar 18 '14 18:03 davidchua