[英]Log changes to a model with Librato
我有一个Devise模型:
class Account < ActiveRecord::Base
devise ::trackable
我想查看在Librato中创建和登录Account
的次数。
使用Librato的日志流解析,您可以使用$stdout.puts
记录事件。
我们可以在lib/librato/account.rb
创建一个文件:
module Librato
module Account
extend ActiveSupport::Concern
included do
after_create do
$stdout.puts 'count#account.create=1'
end
after_save if: :current_sign_in_at_changed? do
$stdout.puts 'count#account.sign_in=1'
end
end
end
end
然后将其包含在模型中,因此:
class Account < ActiveRecord::Base
include Librato::Account
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.