lib/logging.rb in logging-0.1.0 vs lib/logging.rb in logging-0.2.0

- old
+ new

@@ -1,19 +1,23 @@ -# $Id: logging.rb 12 2007-01-14 20:03:40Z tim_pease $ +# $Id: logging.rb 22 2007-01-29 16:20:54Z tim_pease $ require 'logging/repository' # require all appenders require 'logging/appenders/console' require 'logging/appenders/file' +require 'logging/appenders/rolling_file' require 'logging/appenders/static_appender' # require all layouts require 'logging/layouts/basic' require 'logging/layouts/pattern' +# require all configurators +require 'logging/config/yaml_configurator' + # # # module Logging @@ -21,10 +25,25 @@ LNAMES = {} # :nodoc: class << self # # call-seq: + # Logging.configure( filename ) + # + # Configures the Logging framework using the configuration information + # found in the given file. The file extension should be either '.yaml' + # or '.yml' (XML configuration is not yet supported). + # + def configure( filename ) + case File.extname(filename) + when '.yaml', '.yml': + ::Logging::Config::YamlConfigurator.load(filename) + else raise ArgumentError, 'unknown configuration file format' end + end + + # + # call-seq: # define_levels( levels ) # # Defines the levels available to the loggers. The _levels_ is an array # of strings and symbols. Each element in the array is downcased and # converted to a symbol; these symbols are used to create the logging @@ -97,10 +116,12 @@ # # An +ArgumentError+ is raised if anything other than +:string+, # +:inspect+, +:yaml+ is passed to this method. # def format_as( f ) + f = f.intern if f.instance_of? String + unless [:string, :inspect, :yaml].include? f raise ArgumentError, "unknown object format '#{f}'" end module_eval "OBJ_FORMAT = :#{f}" @@ -117,10 +138,10 @@ def level_num( level ) l = levelify level case l when 'all': 0 when 'off': LEVELS.length - else LEVELS[l] end + else begin; Integer(l); rescue ArgumentError; LEVELS[l] end end end # :startdoc: end end # module Logging