lib/semantic_logger/railtie.rb in semantic_logger-0.3.0 vs lib/semantic_logger/railtie.rb in semantic_logger-0.3.1
- old
+ new
@@ -27,11 +27,13 @@
config = Rails.application.config
logger = Rails.logger || config.logger || begin
path = config.paths.log.to_a.first
logger = ActiveSupport::BufferedLogger.new(path)
- logger.level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
+ # Translate trace to debug level for BufferedLogger
+ level = config.log_level == :trace ? :debug : config.log_level
+ logger.level = ActiveSupport::BufferedLogger.const_get(level.to_s.upcase)
logger.auto_flushing = false if Rails.env.production?
logger
rescue StandardError => e
logger = ActiveSupport::BufferedLogger.new(STDERR)
logger.level = ActiveSupport::BufferedLogger::WARN
@@ -48,10 +50,10 @@
# Add the Rails Logger to the list of appenders
SemanticLogger::Logger.appenders << SemanticLogger::Appender::Logger.new(logger)
# Set the default log level based on the Rails config
- SemanticLogger::Logger.default_level = Rails.configuration.log_level
+ SemanticLogger::Logger.default_level = config.log_level
# Replace the default Rails loggers
Rails.logger = config.logger = SemanticLogger::Logger.new(Rails)
if defined?(ActiveRecord)
ActiveRecord::Base.logger = SemanticLogger::Logger.new(ActiveRecord)