class Thoth::Logger
Attributes
outputs[R]
timestamp_format[R]
timestamp_key[R]
Public Class Methods
new(outputs, options={})
click to toggle source
# File lib/thoth/logger.rb, line 6 def initialize(outputs, options={}) @outputs = [outputs].flatten @timestamp_format = options.fetch(:timestamp_format, "%d/%b/%Y:%H:%M:%S %z") @timestamp_key = options.fetch(:timestamp_key, :time) end
Public Instance Methods
log(event_name, details={}, context={})
click to toggle source
# 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()
click to toggle source
lazy load this since this class is initialized before rails' filter_parameters is set
# File lib/thoth/logger.rb, line 13 def param_filter @param_filter ||= ::ActionDispatch::Http::ParameterFilter.new(::Rails.application.config.filter_parameters) end
Private Instance Methods
marshal_event(event_name, details, context)
click to toggle source
# File lib/thoth/logger.rb, line 28 def marshal_event(event_name, details, context) param_filter.filter({ event: event_name, timestamp_key => Time.now.utc.strftime(timestamp_format), context: context.reverse_merge(Thoth.context), details: details }) end