2013-05-27 16:15:17 +02:00
|
|
|
require "rails_big_brother/version"
|
2013-05-28 10:38:20 +02:00
|
|
|
require "rails_big_brother/controller"
|
|
|
|
require "rails_big_brother/model"
|
2013-05-27 16:15:17 +02:00
|
|
|
|
|
|
|
module RailsBigBrother
|
2013-05-28 12:01:15 +02:00
|
|
|
def format=(value)
|
|
|
|
@format = value
|
|
|
|
end
|
|
|
|
|
|
|
|
def format
|
|
|
|
@format ||= "%<big_brother>s;%<user>s;%<controller_info>s;%<class>s;%<id>s;%<action>s;%<args>s"
|
|
|
|
end
|
|
|
|
|
2013-05-28 10:38:20 +02:00
|
|
|
def user=(value)
|
|
|
|
store[:user] = value
|
|
|
|
end
|
|
|
|
|
|
|
|
def user
|
|
|
|
store[:user]
|
|
|
|
end
|
|
|
|
|
|
|
|
def controller_info=(value)
|
|
|
|
store[:controller_info] = value
|
|
|
|
end
|
|
|
|
|
|
|
|
def controller_info
|
|
|
|
store[:controller_info]
|
|
|
|
end
|
|
|
|
|
|
|
|
def controller_info_string
|
|
|
|
case controller_info
|
|
|
|
when Array
|
|
|
|
controller_info.join(',')
|
|
|
|
when Hash
|
|
|
|
controller_info.map { |k,v| "#{k}:#{v}" }.join(',')
|
|
|
|
else
|
|
|
|
controller_info
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def store
|
|
|
|
Thread.current[:big_brother_log] ||= {}
|
|
|
|
end
|
|
|
|
|
|
|
|
extend self
|
|
|
|
end
|
|
|
|
|
|
|
|
ActiveSupport.on_load(:active_record) do
|
|
|
|
include RailsBigBrother::Model
|
|
|
|
end
|
|
|
|
|
|
|
|
ActiveSupport.on_load(:action_controller) do
|
|
|
|
include RailsBigBrother::Controller
|
2013-05-27 16:15:17 +02:00
|
|
|
end
|