Log Subscriber
继承于 Subscriber.
Rails 各个模块里的 LogSubscriber
|
V
LogSubscriber
|
V
Subscriber类方法:
flush_all!
log_subscribers
logger实例方法:
finish
start
logger其它实例方法:
info
debug
warn
error
fatal
unknown和
color使用举例:
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最后更新于
这有帮助吗?