lib/logging/config/yaml_configurator.rb in logging-0.4.0 vs lib/logging/config/yaml_configurator.rb in logging-0.5.0
- old
+ new
@@ -1,23 +1,22 @@
-# $Id: yaml_configurator.rb 22 2007-01-29 16:20:54Z tim_pease $
+# $Id: yaml_configurator.rb 37 2007-10-26 19:12:44Z tim_pease $
require 'yaml'
require 'logging'
module Logging
module Config
- #
# The YamlConfigurator class is used to configure the Logging framework
# using information found in a YAML file.
#
class YamlConfigurator
class Error < StandardError; end # :nodoc:
class << self
- #
+
# call-seq:
# YamlConfigurator.load( file )
#
# Load the given YAML _file_ and use it to configure the Logging
# framework. The file can be either a filename, and open File, or an
@@ -36,11 +35,10 @@
begin new(io).load; ensure; io.close if close end
nil
end
end # class << self
- #
# call-seq:
# YamlConfigurator.new( io )
#
# Creates a new YAML configurator that will load the Logging
# configuration from the given _io_ stream.
@@ -55,11 +53,10 @@
raise Error, "Key 'logging_config' not defined in YAML configuration"
end
end
private :initialize
- #
# call-seq:
# load
#
# Loads the Logging configuration from the data loaded from the YAML
# file.
@@ -68,11 +65,10 @@
pre_config @config['pre_config']
appenders @config['appenders']
loggers @config['loggers']
end
- #
# call-seq:
# pre_config( config )
#
# Configures the logging levels, object format style, and root logging
# level.
@@ -95,11 +91,10 @@
if config.has_key?('root')
root.level = config['root']['level']
end
end
- #
# call-seq:
# appenders( ary )
#
# Given an array of Appender configurations, this method will iterate
# over each and create the Appender(s).
@@ -108,11 +103,10 @@
return if ary.nil?
ary.each {|h| appender(h)}
end
- #
# call-seq:
# loggers( ary )
#
# Given an array of Logger configurations, this method will iterate over
# each and create the Logger(s).
@@ -133,11 +127,10 @@
l.appenders = config['appenders'].map {|n| ::Logging::Appender[n]}
end
end
end
- #
# call-seq:
# appender( config )
#
# Creates a new Appender based on the given _config_ options (a hash).
# The type of Appender created is determined by the 'type' option in the
@@ -161,10 +154,9 @@
clazz = ::Logging::Appenders.const_get type
clazz.new(name, config)
end
- #
# call-seq:
# layout( config )
#
# Creates a new Layout based on the given _config_ options (a hash).
# The type of Layout created is determined by the 'type' option in the