Add possibility to specify a different format for log
parent
4ebb0c52f1
commit
3310b4502c
|
@ -3,6 +3,14 @@ require "rails_big_brother/controller"
|
|||
require "rails_big_brother/model"
|
||||
|
||||
module RailsBigBrother
|
||||
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
|
||||
|
||||
def user=(value)
|
||||
store[:user] = value
|
||||
end
|
||||
|
|
|
@ -43,10 +43,16 @@ module RailsBigBrother
|
|||
end
|
||||
|
||||
def big_brother_log(action, *args)
|
||||
# TODO RailsBigBrother.format, RailsBigBrother.separator
|
||||
Rails.logger.info "big_brother;#{RailsBigBrother.user};" <<
|
||||
"#{RailsBigBrother.controller_info_string};" <<
|
||||
"#{self.class.name};#{self.to_param};#{action};#{args.join(';')}"
|
||||
Rails.logger.info RailsBigBrother.format %
|
||||
{
|
||||
big_brother: "big_brother",
|
||||
user: RailsBigBrother.user,
|
||||
controller_info: RailsBigBrother.controller_info_string,
|
||||
class: self.class.name,
|
||||
id: self.to_param,
|
||||
action: action,
|
||||
args: args.join(',')
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue