lib/dldinternet/mixlib/logging.rb in dldinternet-mixlib-logging-0.6.1 vs lib/dldinternet/mixlib/logging.rb in dldinternet-mixlib-logging-0.6.2

- old
+ new

@@ -469,19 +469,27 @@ puts "#{args[:origins][:log_level]} says #{args[:log_level]}".light_yellow else from = '' end end - l_opts = args[:log_opts].call(::Logging::MAX_LEVEL_LENGTH) || { - :pattern => "#{from}%d %#{::Logging::MAX_LEVEL_LENGTH}l: %m\n", - :date_pattern => '%Y-%m-%d %H:%M:%S', - } - logger = ::Logging.logger( STDOUT, l_opts) - l_opts = args[:log_opts].call(::Logging::MAX_LEVEL_LENGTH) || { - :pattern => "#{from}%d %#{::Logging::MAX_LEVEL_LENGTH}l: %m %C\n", - :date_pattern => '%Y-%m-%d %H:%M:%S', - } + l_opts = if args[:log_opts].is_a?(Proc) + args[:log_opts].call(::Logging::MAX_LEVEL_LENGTH) || { + :pattern => "#{from}%d %#{::Logging::MAX_LEVEL_LENGTH}l: %m\n", + :date_pattern => '%Y-%m-%d %H:%M:%S', + } + else + args[:log_opts] + end + logger = ::Logging.logger( $stdout, l_opts) + l_opts = if args[:log_opts].is_a?(Proc) + args[:log_opts].call(::Logging::MAX_LEVEL_LENGTH) || { + :pattern => "#{from}%d %#{::Logging::MAX_LEVEL_LENGTH}l: %m %C\n", + :date_pattern => '%Y-%m-%d %H:%M:%S', + } + else + args[:log_opts] + end layout = ::Logging::Layouts::Pattern.new(l_opts) if args[:log_file] and args[:log_file].instance_of?(String) dev = args[:log_file] a_opts = Hash.new @@ -529,14 +537,16 @@ appender.layout = layout logger.remove_appenders appender logger.add_appenders appender logger.level = args[:log_level] ? args[:log_level] : :warn - unless ::Logging::VERSION =~ /^2/ - logger.trace = true if args[:trace] - else - logger.caller_tracing = true if args[:trace] - end + if args[:trace] + if ::Logging::VERSION =~ /^2/ + logger.caller_tracing = true + else + logger.trace = true + end + end @logger_args = args rescue Gem::LoadError logger = FakeLogger.new rescue Exception => e puts e