Class: Shoryuken::Logging::Base
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- Shoryuken::Logging::Base
- Defined in:
- lib/shoryuken/logging/base.rb
Overview
Base formatter class that provides common functionality for Shoryuken log formatters. Provides thread ID generation and context management.
Direct Known Subclasses
Instance Method Summary collapse
-
#context ⇒ String
Returns the current logging context as a formatted string.
-
#tid ⇒ String
Generates a thread ID for the current thread.
Instance Method Details
#context ⇒ String
Returns the current logging context as a formatted string. Context is set using Shoryuken::Logging.with_context.
20 21 22 23 |
# File 'lib/shoryuken/logging/base.rb', line 20 def context c = Thread.current[:shoryuken_context] c ? " #{c}" : '' end |
#tid ⇒ String
Generates a thread ID for the current thread. Uses a combination of thread object_id and process ID to create a unique identifier.
12 13 14 |
# File 'lib/shoryuken/logging/base.rb', line 12 def tid Thread.current['shoryuken_tid'] ||= (Thread.current.object_id ^ ::Process.pid).to_s(36) end |