Class: Fractor::Workflow::WorkflowLogger

Inherits:
Object
  • Object
show all
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

StructuredLogger

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (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

#loggerObject (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(message, context = {})
  log(:debug, message, 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(message, context = {})
  log(:error, message, 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(message, context = {})
  log(:info, message, 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(message, context = {})
  log(:warn, message, context)
end