Class: Sentry::DebugTransport
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Sentry::DebugTransport
- Defined in:
- lib/sentry/transport/debug_transport.rb
Overview
DebugTransport is a transport that logs events to a file for debugging purposes.
It can optionally also send events to Sentry via HTTP transport if a real DSN is provided.
Constant Summary collapse
- DEFAULT_LOG_FILE_PATH =
File.join("log", "sentry_debug_events.log")
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#log_file ⇒ Object
readonly
Returns the value of attribute log_file.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(configuration) ⇒ DebugTransport
constructor
A new instance of DebugTransport.
- #log_envelope(envelope) ⇒ Object
- #logged_envelopes ⇒ Object
- #send_envelope(envelope) ⇒ Object
- #send_event(event) ⇒ Object
- #start_run ⇒ Object
Constructor Details
#initialize(configuration) ⇒ DebugTransport
Returns a new instance of DebugTransport.
80 81 82 83 84 85 86 |
# File 'lib/sentry/transport/debug_transport.rb', line 80 def initialize(configuration) @log = DebugLogFile.new(configuration.sdk_debug_transport_log_file, File.basename(DEFAULT_LOG_FILE_PATH, ".log")) @log_file = @log.path @backend = initialize_backend(configuration) super(@backend) end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
78 79 80 |
# File 'lib/sentry/transport/debug_transport.rb', line 78 def backend @backend end |
#log_file ⇒ Object (readonly)
Returns the value of attribute log_file.
78 79 80 |
# File 'lib/sentry/transport/debug_transport.rb', line 78 def log_file @log_file end |
Instance Method Details
#clear ⇒ Object
118 119 120 121 |
# File 'lib/sentry/transport/debug_transport.rb', line 118 def clear @log.clear log_debug("DebugTransport: Cleared events from #{log_file}") end |
#log_envelope(envelope) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/sentry/transport/debug_transport.rb', line 98 def log_envelope(envelope) envelope_json = { timestamp: Time.now.utc.iso8601, envelope_headers: envelope.headers, items: envelope.items.map do |item| { headers: item.headers, payload: item.payload } end } @log.append(envelope_json) end |
#logged_envelopes ⇒ Object
110 111 112 |
# File 'lib/sentry/transport/debug_transport.rb', line 110 def logged_envelopes @log.entries end |
#send_envelope(envelope) ⇒ Object
93 94 95 96 |
# File 'lib/sentry/transport/debug_transport.rb', line 93 def send_envelope(envelope) log_envelope(envelope) backend.send_envelope(envelope) end |
#send_event(event) ⇒ Object
88 89 90 91 |
# File 'lib/sentry/transport/debug_transport.rb', line 88 def send_event(event) log_envelope(envelope_from_event(event)) backend.send_event(event) end |
#start_run ⇒ Object
114 115 116 |
# File 'lib/sentry/transport/debug_transport.rb', line 114 def start_run @log.start_run end |