Module: SmartLogger
- Defined in:
- lib/smart_logger/rack.rb,
lib/smart_logger.rb,
lib/smart_logger/resque.rb
Overview
Defined Under Namespace
Modules: Job Classes: RackLoggerMarker
Class Method Summary collapse
-
.add(name, value) ⇒ Object
Adds extra tags to the log file.
-
.end ⇒ Object
Mark the end of an action.
- .format_message(severity, message = nil, progname = nil) ⇒ Object
-
.initialize(name = 'InitProcess') ⇒ Object
Initialize smart logger.
-
.params ⇒ Object
Returns a list of parameters for this action.
-
.start(action) ⇒ Object
Mark the start of a new action, creating a new water-mark.
-
.water_mark ⇒ Object
Returns the current water mark.
Class Method Details
.add(name, value) ⇒ Object
37 38 39 40 |
# File 'lib/smart_logger.rb', line 37 def self.add(name, value) create_watermark if self.water_mark.nil? save_param(name, value) end |
.end ⇒ Object
Mark the end of an action
24 25 26 27 |
# File 'lib/smart_logger.rb', line 24 def self.end create_watermark reset_params end |
.format_message(severity, message = nil, progname = nil) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/smart_logger.rb', line 72 def self.(severity, = nil, progname = nil) "[%s%s] [%s: %s] %s\n" % [ SmartLogger::water_mark, SmartLogger::params, severity, Time.zone.now.strftime("%H:%M:%S"), ( || progname).to_s.lstrip] end |
.initialize(name = 'InitProcess') ⇒ Object
67 68 69 70 |
# File 'lib/smart_logger.rb', line 67 def self.initialize(name = 'InitProcess') Rails.configuration.middleware.insert_before Rails::Rack::Logger, SmartLogger::RackLoggerMarker SmartLogger.start(name) end |
.params ⇒ Object
Returns a list of parameters for this action
46 47 48 49 50 |
# File 'lib/smart_logger.rb', line 46 def self.params Thread.current[:logger_params].inject('') do |str, val| str << " #{val[0].to_s}:#{val[1]}" end rescue '' end |
.start(action) ⇒ Object
17 18 19 20 |
# File 'lib/smart_logger.rb', line 17 def self.start(action) create_watermark save_param(:action, action) end |
.water_mark ⇒ Object
Returns the current water mark
56 57 58 |
# File 'lib/smart_logger.rb', line 56 def self.water_mark Thread.current[:logger_mark] end |