Class: Log4r::YamlConfigurator
- Inherits:
-
Object
- Object
- Log4r::YamlConfigurator
- Defined in:
- lib/log4r/core_ext/yamlconfigurator.rb
Overview
Log4r::YamlConfigurator extension
Class Method Summary collapse
-
.actual_load(yaml_docs) ⇒ Object
Loads a stream of YAML documents from disk given by
yaml_docs
. -
.decode_yaml(cfg) ⇒ Object
Decodes the list of configuration given by
cfg
.
Class Method Details
.actual_load(yaml_docs) ⇒ Object
Loads a stream of YAML documents from disk given by yaml_docs
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/log4r/core_ext/yamlconfigurator.rb', line 20 def self.actual_load(yaml_docs) log4r_config = nil Psych.load_stream(yaml_docs) { |doc| doc.has_key?('log4r_config') and log4r_config = doc['log4r_config'] and break } if log4r_config.nil? raise ConfigError, "Key 'log4r_config:' not defined in yaml documents", caller[1..-1] end decode_yaml(log4r_config) end |
.decode_yaml(cfg) ⇒ Object
Decodes the list of configuration given by cfg
.
Can contain the following lists of configurations:
-
outputters
-
loggers
-
logserver
12 13 14 15 16 17 |
# File 'lib/log4r/core_ext/yamlconfigurator.rb', line 12 def self.decode_yaml(cfg) decode_pre_config(cfg['pre_config']) cfg['outputters'].each { |op| decode_outputter(op) } unless cfg['outputters'].nil? cfg['loggers'].each { |lo| decode_logger(lo) } unless cfg['loggers'].nil? cfg['logserver'].each { |lo| decode_logserver(lo) } unless cfg['logserver'].nil? end |