[英]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.