-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
If I would like to externalize the logging level using by example a variable with the name "LOGGING_LEVEL" as such within the yml config file
log4r_config:
# define all loggers ...
loggers:
- name : production
level : "#{LOGGING_LEVEL}"
Code
if level.nil?
cfg['LOGGING_LEVEL'] = 'INFO'
else
cfg['LOGGING_LEVEL'] = levels[level]
end
cfg.decode_yaml log4r_f['log4r_config']
then log4r raise the following exception
/Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:189:in `decode_logger_common': Log level must be in 0..7 (ArgumentError)
from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:175:in `decode_logger'
from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:69:in `block in decode_yaml'
from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:69:in `each'
from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:69:in `decode_yaml'
from /Users/chmoulli/MyProjects/hyla/lib/hyla/logger2.rb:37:in `initialize'
It seems that the file is parsed first with the hash{variable} and replacement is done after the parsing but of course that fails for the LEVEL as it tries to read the string of the hash string
Metadata
Metadata
Assignees
Labels
No labels