Class: Thoth::Logger
- Inherits:
-
Object
- Object
- Thoth::Logger
- Defined in:
- lib/thoth/logger.rb
Instance Attribute Summary collapse
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#timestamp_format ⇒ Object
readonly
Returns the value of attribute timestamp_format.
-
#timestamp_key ⇒ Object
readonly
Returns the value of attribute timestamp_key.
Instance Method Summary collapse
-
#initialize(outputs, options = {}) ⇒ Logger
constructor
A new instance of Logger.
- #log(event_name, details = {}, context = {}) ⇒ Object
-
#param_filter ⇒ Object
lazy load this since this class is initialized before rails’ filter_parameters is set.
Constructor Details
#initialize(outputs, options = {}) ⇒ Logger
Returns a new instance of Logger.
6 7 8 9 10 |
# File 'lib/thoth/logger.rb', line 6 def initialize(outputs, ={}) @outputs = [outputs].flatten @timestamp_format = .fetch(:timestamp_format, "%d/%b/%Y:%H:%M:%S %z") @timestamp_key = .fetch(:timestamp_key, :time) end |
Instance Attribute Details
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
4 5 6 |
# File 'lib/thoth/logger.rb', line 4 def outputs @outputs end |
#timestamp_format ⇒ Object (readonly)
Returns the value of attribute timestamp_format.
4 5 6 |
# File 'lib/thoth/logger.rb', line 4 def @timestamp_format end |
#timestamp_key ⇒ Object (readonly)
Returns the value of attribute timestamp_key.
4 5 6 |
# File 'lib/thoth/logger.rb', line 4 def @timestamp_key end |
Instance Method Details
#log(event_name, details = {}, context = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/thoth/logger.rb', line 17 def log(event_name, details={}, context={}) event_data = marshal_event(event_name, details, context) outputs.each do |output| output.write(event_data) end end |
#param_filter ⇒ Object
lazy load this since this class is initialized before rails’ filter_parameters is set
13 14 15 |
# File 'lib/thoth/logger.rb', line 13 def param_filter @param_filter ||= ::ActionDispatch::Http::ParameterFilter.new(::Rails.application.config.filter_parameters) end |