From 3310b4502c1e4b1355c815834fc99ff46dd4845f Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Tue, 28 May 2013 12:01:15 +0200 Subject: [PATCH] Add possibility to specify a different format for log --- lib/rails_big_brother.rb | 8 ++++++++ lib/rails_big_brother/model.rb | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/rails_big_brother.rb b/lib/rails_big_brother.rb index cc4e37d..1ff3826 100644 --- a/lib/rails_big_brother.rb +++ b/lib/rails_big_brother.rb @@ -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 ||= "%s;%s;%s;%s;%s;%s;%s" + end + def user=(value) store[:user] = value end diff --git a/lib/rails_big_brother/model.rb b/lib/rails_big_brother/model.rb index 1f4d778..18d7e24 100644 --- a/lib/rails_big_brother/model.rb +++ b/lib/rails_big_brother/model.rb @@ -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