Module: LanguageOperator::Loggable

Overview

Mixin module to provide automatic logger initialization for classes that need logging capabilities.

The logger component name is automatically derived from the class name. You can override the component name by defining a logger_component method.

Examples:

class MyClass
  include LanguageOperator::Loggable

  def process
    logger.info("Processing started")
    # ...
  end
end

Custom component name

class MyClass
  include LanguageOperator::Loggable

  def logger_component
    'CustomName'
  end
end

Instance Method Summary collapse

Instance Method Details

#loggerLanguageOperator::Logger

Returns a logger instance for this class. Lazily initializes the logger on first access.

Returns:



33
34
35
# File 'lib/language_operator/loggable.rb', line 33

def logger
  @logger ||= LanguageOperator::Logger.new(component: logger_component)
end