lib/ezlog/railtie.rb in ezlog-0.3.2 vs lib/ezlog/railtie.rb in ezlog-0.3.3
- old
+ new
@@ -3,12 +3,12 @@
initializer 'ezlog.configure_logging' do |app|
::Logging.logger.root.appenders = ::Logging.appenders.stdout 'stdout', layout: Ezlog::LoggingLayout.new(environment: ::Rails.env)
::Logging.logger.root.level = app.config.log_level
end
- initializer 'ezlog.configure_sidekiq_logging' do
- initialize_sidekiq_logging if defined? ::Sidekiq
+ initializer 'ezlog.configure_sidekiq_logging' do |app|
+ initialize_sidekiq_logging(app) if defined? ::Sidekiq
end
initializer 'ezlog.configure_rack_timeout_logging' do
disable_rack_timeout_logging if defined? ::Rack::Timeout
end
@@ -25,17 +25,17 @@
Ezlog::Rails::LogSubscriber.detach ::ActionView::LogSubscriber
end
config.before_configuration do |app|
app.config.logger = Ezlog.logger('Application')
- app.config.log_level = :info
+ app.config.log_level = ENV['LOG_LEVEL'] || :info
end
private
- def initialize_sidekiq_logging
+ def initialize_sidekiq_logging(app)
::Sidekiq.logger = Ezlog.logger('Sidekiq')
- ::Sidekiq.logger.level = :info
+ ::Sidekiq.logger.level = app.config.log_level
::Sidekiq.configure_server do |config|
config.options[:job_logger] = Ezlog::Sidekiq::JobLogger
config.error_handlers << Ezlog::Sidekiq::ErrorLogger.new
config.error_handlers.delete_if { |handler| handler.is_a? ::Sidekiq::ExceptionHandler::Logger }
end