#log_level added, rack-logger 3.2.9 -compatible

This commit is contained in:
Denis Knauf 2012-11-19 17:07:39 +01:00
parent fd8860766b
commit 26853e31e2
2 changed files with 8 additions and 6 deletions

View file

@ -64,6 +64,11 @@ class Semlogger < ::Logger
end end
attr_accessor :logdev, :level, :progname attr_accessor :logdev, :level, :progname
# some libs use #log_level
def log_level=( level) @level = level end
def log_level() @level end
class <<self class <<self
attr_accessor :progname, :logger attr_accessor :progname, :logger
@ -110,9 +115,7 @@ class Semlogger < ::Logger
def add severity, message = nil, progname = nil, &block def add severity, message = nil, progname = nil, &block
severity ||= UNKNOWN severity ||= UNKNOWN
if @logdev.nil? or severity < @level return true if @logdev.nil? or severity < @level
return true
end
progname ||= @progname progname ||= @progname
if message.nil? if message.nil?
if block_given? if block_given?

View file

@ -4,10 +4,9 @@ class Semlogger::Rack < Rails::Rack::Logger
@data = data @data = data
end end
def call_app env def call_app request, env
request = ActionDispatch::Request.new env
path = request.filtered_path path = request.filtered_path
Rails.logger.info Semlogger.custom :connection, request.ip, Thread.current.object_id, request.request_method, path Semlogger.custom( :connection, request.ip, Thread.current.object_id, request.request_method, path).info
@app.call env @app.call env
ensure ensure
ActiveSupport::LogSubscriber.flush_all! ActiveSupport::LogSubscriber.flush_all!