Class: Startback::Audit::TraceLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/startback/audit/trace_logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger = default_logger) ⇒ TraceLogger

Returns a new instance of TraceLogger.



5
6
7
8
# File 'lib/startback/audit/trace_logger.rb', line 5

def initialize(logger = default_logger)
  @logger = logger || default_logger
  @logger.formatter ||= Support::LogFormatter.new if @logger.respond_to?(:formatter=)
end

Instance Method Details

#call(span) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/startback/audit/trace_logger.rb', line 10

def call(span)
  if !span.finished?
    @logger.debug(span.to_h)
  elsif span.success?
    @logger.info(span.to_h)
  elsif span&.error.is_a?(Startback::Errors::BadRequestError)
    @logger.warn(span.to_h)
  else
    @logger.error(span.to_h)
  end
end