Configurable ruby logger setup: Logger.new().level = variable
Posted
by Daniel
on Stack Overflow
See other posts from Stack Overflow
or by Daniel
Published on 2010-04-05T15:55:38Z
Indexed on
2010/04/05
16:13 UTC
Read the original article
Hit count: 468
Hi,
I want to change the logging level of an application (ruby).
require 'logger'
config = { :level => 'Logger::WARN' }
log = Logger.new STDOUT
log.level = Kernel.const_get config[:level]
Well, the irb wasn't happy with that and threw "NameError: wrong constant name Logger::WARN" in my face. Ugh! I was insulted.
I could do this in a case/when to solve this, or do log.level = 1, but there must be a more elegant way!
Does anyone have any ideas?
-daniel
© Stack Overflow or respective owner