Module: Aidp::Interfaces::LoggerInterface

Included in:
AidpLoggerAdapter, NullLogger
Defined in:
lib/aidp/interfaces/logger_interface.rb

Overview

LoggerInterface defines the contract for logging implementations. This interface allows for dependency injection of different logging backends, facilitating extraction of provider code into standalone gems.

All logging methods follow a consistent signature:

log_<level>(component, message, **metadata)

Where:

- component: String identifying the subsystem (e.g., "anthropic_provider")
- message: String describing the event (e.g., "rate_limit_detected")
- metadata: Optional keyword arguments for structured logging context

Examples:

Implementing the interface

class MyLogger
  include Aidp::Interfaces::LoggerInterface

  def log_debug(component, message, **)
    puts "[DEBUG] #{component}: #{message} #{}"
  end

  def log_info(component, message, **)
    puts "[INFO] #{component}: #{message} #{}"
  end

  def log_warn(component, message, **)
    puts "[WARN] #{component}: #{message} #{}"
  end

  def log_error(component, message, **)
    puts "[ERROR] #{component}: #{message} #{}"
  end
end

Using an injected logger

class Provider
  def initialize(logger: Aidp::Interfaces::NullLogger.new)
    @logger = logger
  end

  def perform_action
    @logger.log_debug("provider", "action_started", action: "perform")
  end
end

Instance Method Summary collapse

Instance Method Details

#log_debug(component, message, **metadata) ⇒ void

This method returns an undefined value.

Log a debug-level message. Use for detailed diagnostic information useful during development.

Parameters:

  • component (String)

    the subsystem or module name

  • message (String)

    the log message

  • metadata (Hash)

    optional structured key-value pairs

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/aidp/interfaces/logger_interface.rb', line 57

def log_debug(component, message, **)
  raise NotImplementedError, "#{self.class} must implement #log_debug"
end

#log_error(component, message, **metadata) ⇒ void

This method returns an undefined value.

Log an error-level message. Use for error events that might still allow operation to continue.

Parameters:

  • component (String)

    the subsystem or module name

  • message (String)

    the log message

  • metadata (Hash)

    optional structured key-value pairs

Raises:

  • (NotImplementedError)


90
91
92
# File 'lib/aidp/interfaces/logger_interface.rb', line 90

def log_error(component, message, **)
  raise NotImplementedError, "#{self.class} must implement #log_error"
end

#log_info(component, message, **metadata) ⇒ void

This method returns an undefined value.

Log an info-level message. Use for general operational events that don't indicate problems.

Parameters:

  • component (String)

    the subsystem or module name

  • message (String)

    the log message

  • metadata (Hash)

    optional structured key-value pairs

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/aidp/interfaces/logger_interface.rb', line 68

def log_info(component, message, **)
  raise NotImplementedError, "#{self.class} must implement #log_info"
end

#log_warn(component, message, **metadata) ⇒ void

This method returns an undefined value.

Log a warning-level message. Use for potentially problematic situations that don't prevent operation.

Parameters:

  • component (String)

    the subsystem or module name

  • message (String)

    the log message

  • metadata (Hash)

    optional structured key-value pairs

Raises:

  • (NotImplementedError)


79
80
81
# File 'lib/aidp/interfaces/logger_interface.rb', line 79

def log_warn(component, message, **)
  raise NotImplementedError, "#{self.class} must implement #log_warn"
end