Class: DebugBundle::Logging::SemanticLoggerAppender

Inherits:
Object
  • Object
show all
Defined in:
lib/debugbundle/logging.rb

Instance Method Summary collapse

Constructor Details

#initialize(client: DebugBundle.client) ⇒ SemanticLoggerAppender

Returns a new instance of SemanticLoggerAppender.



54
55
56
# File 'lib/debugbundle/logging.rb', line 54

def initialize(client: DebugBundle.client)
  @client = client
end

Instance Method Details

#log(log) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/debugbundle/logging.rb', line 58

def log(log)
  was_capturing = Thread.current[RECURSION_GUARD_KEY]
  return if was_capturing

  Thread.current[RECURSION_GUARD_KEY] = true
  @client.capture_log(
    log.message,
    level: log.level || :info,
    context: {
      logger_name: log.name,
      payload: log.payload,
      tags: log.tags
    }
  )
ensure
  Thread.current[RECURSION_GUARD_KEY] = was_capturing
end