Class: Fractor::Workflow::WorkflowLogger
- Inherits:
-
Object
- Object
- Fractor::Workflow::WorkflowLogger
- Defined in:
- lib/fractor/workflow/logger.rb
Overview
Logger wrapper for workflow execution logging. Provides structured logging with correlation IDs and context.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#child(additional_context = {}) ⇒ Object
Create a child logger with additional context.
-
#debug(message, context = {}) ⇒ Object
Log a debug message with structured context.
-
#error(message, context = {}) ⇒ Object
Log an error message with structured context.
-
#info(message, context = {}) ⇒ Object
Log an info message with structured context.
-
#initialize(logger: nil, correlation_id: nil) ⇒ WorkflowLogger
constructor
A new instance of WorkflowLogger.
-
#warn(message, context = {}) ⇒ Object
Log a warning message with structured context.
Constructor Details
#initialize(logger: nil, correlation_id: nil) ⇒ WorkflowLogger
Returns a new instance of WorkflowLogger.
14 15 16 17 |
# File 'lib/fractor/workflow/logger.rb', line 14 def initialize(logger: nil, correlation_id: nil) @logger = logger || default_logger @correlation_id = correlation_id || generate_correlation_id end |
Instance Attribute Details
#correlation_id ⇒ Object (readonly)
Returns the value of attribute correlation_id.
12 13 14 |
# File 'lib/fractor/workflow/logger.rb', line 12 def correlation_id @correlation_id end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/fractor/workflow/logger.rb', line 12 def logger @logger end |
Instance Method Details
#child(additional_context = {}) ⇒ Object
Create a child logger with additional context
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fractor/workflow/logger.rb', line 40 def child(additional_context = {}) child_logger = self.class.new( logger: @logger, correlation_id: @correlation_id, ) child_logger.instance_variable_set( :@base_context, base_context.merge(additional_context), ) child_logger end |
#debug(message, context = {}) ⇒ Object
Log a debug message with structured context
35 36 37 |
# File 'lib/fractor/workflow/logger.rb', line 35 def debug(, context = {}) log(:debug, , context) end |
#error(message, context = {}) ⇒ Object
Log an error message with structured context
30 31 32 |
# File 'lib/fractor/workflow/logger.rb', line 30 def error(, context = {}) log(:error, , context) end |
#info(message, context = {}) ⇒ Object
Log an info message with structured context
20 21 22 |
# File 'lib/fractor/workflow/logger.rb', line 20 def info(, context = {}) log(:info, , context) end |
#warn(message, context = {}) ⇒ Object
Log a warning message with structured context
25 26 27 |
# File 'lib/fractor/workflow/logger.rb', line 25 def warn(, context = {}) log(:warn, , context) end |