mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
avoid proc activation every time a log message is made
This commit is contained in:
@@ -63,15 +63,9 @@ module ActiveSupport
|
||||
@@flushable_loggers = nil
|
||||
|
||||
log_subscriber.public_methods(false).each do |event|
|
||||
notifier.subscribe("#{event}.#{namespace}") do |*args|
|
||||
next if log_subscriber.logger.nil?
|
||||
next if 'call' == event.to_s
|
||||
|
||||
begin
|
||||
log_subscriber.send(event, ActiveSupport::Notifications::Event.new(*args))
|
||||
rescue Exception => e
|
||||
log_subscriber.logger.error "Could not log #{args[0].inspect} event. #{e.class}: #{e.message}"
|
||||
end
|
||||
end
|
||||
notifier.subscribe("#{event}.#{namespace}", log_subscriber)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -92,6 +86,17 @@ module ActiveSupport
|
||||
flushable_loggers.each(&:flush)
|
||||
end
|
||||
|
||||
def call(message, *args)
|
||||
return unless logger
|
||||
|
||||
method = message.split('.').first
|
||||
begin
|
||||
send(method, ActiveSupport::Notifications::Event.new(message, *args))
|
||||
rescue Exception => e
|
||||
logger.error "Could not log #{message.inspect} event. #{e.class}: #{e.message}"
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
%w(info debug warn error fatal unknown).each do |level|
|
||||
|
||||
Reference in New Issue
Block a user