继承于 Subscriber.
Rails 各个模块里的 LogSubscriber
|
V
LogSubscriber
|
V
Subscriber
flush_all!
log_subscribers
logger
info
debug
warn
error
fatal
unknown
module ActiveRecord
class LogSubscriber < ActiveSupport::LogSubscriber
def sql(event)
"#{event.payload[:name]} (#{event.duration}) #{event.payload[:sql]}"
end
end
end
ActiveRecord::LogSubscriber.attach_to :active_record