lib/logjam_agent/railtie.rb in logjam_agent-0.24.3 vs lib/logjam_agent/railtie.rb in logjam_agent-0.24.4
- old
+ new
@@ -14,11 +14,11 @@
end
initializer "initialize_logjam_agent_logger", :before => :initialize_logger do |app|
Rails.logger ||= app.config.logger ||
begin
- path = logjam_log_path(app)
+ path = ENV["RAILS_LOG_TO_STDOUT"].present? ? STDOUT : logjam_log_path(app)
logger = LogjamAgent::BufferedLogger.new(path)
logger.level = ::Logger.const_get(app.config.log_level.to_s.upcase)
LogjamAgent.log_device_log_level = logger.level
logger.formatter = LogjamAgent::SyslogLikeFormatter.new
logger.auto_flushing = false if Rails.env.production? && Rails::VERSION::STRING < "3.2"
@@ -55,12 +55,12 @@
require 'logjam_agent/actionpack/lib/action_dispatch/middleware/remote_ip'
app.config.middleware.insert_before LogjamAgent::Middleware, LogjamAgent::ActionDispatch::RemoteIp
end
# install a default error handler for forwarding errors
- log_dir = File.dirname(logjam_log_path(app))
+ log_path = ENV["RAILS_LOG_TO_STDOUT"].present? ? STDERR : File.dirname(logjam_log_path(app)) + "/logjam_agent_error.log"
begin
- forwarding_error_logger = ::Logger.new("#{log_dir}/logjam_agent_error.log")
+ forwarding_error_logger = ::Logger.new(log_path)
rescue StandardError
forwarding_error_logger = ::Logger.new(STDERR)
end
forwarding_error_logger.level = ::Logger::ERROR
forwarding_error_logger.formatter = ::Logger::Formatter.new