Module: Roast::Log

Extended by:
Log
Includes:
Kernel
Included in:
Log
Defined in:
lib/roast/log.rb

Overview

Central logging interface for Roast.

Provides a simple, testable logging API that wraps the standard library Logger and leverages Roast’s Event framework for clean async task integration with proper task hierarchy attribution. Outputs to STDERR by default.

Examples:

Basic usage

Roast::Log.info("Processing file...")
Roast::Log.debug("Detailed info here")
Roast::Log.warn("Something unexpected")
Roast::Log.error("Something failed")

Custom logger

Roast::Log.logger = Rails.logger

Defined Under Namespace

Classes: Message

Constant Summary collapse

LOG_LEVELS =
{
  DEBUG: ::Logger::DEBUG,
  INFO: ::Logger::INFO,
  WARN: ::Logger::WARN,
  ERROR: ::Logger::ERROR,
  FATAL: ::Logger::FATAL,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

: () -> Logger



86
87
88
# File 'lib/roast/log.rb', line 86

def logger
  @logger ||= create_logger
end

Instance Method Details

#debug(message) ⇒ Object

: (String) -> void



56
57
58
# File 'lib/roast/log.rb', line 56

def debug(message)
  Roast::Event << { debug: message }
end

#error(message) ⇒ Object

: (String) -> void



71
72
73
# File 'lib/roast/log.rb', line 71

def error(message)
  Roast::Event << { error: message }
end

#fatal(message) ⇒ Object

: (String) -> void



76
77
78
# File 'lib/roast/log.rb', line 76

def fatal(message)
  Roast::Event << { fatal: message }
end

#info(message) ⇒ Object

: (String) -> void



61
62
63
# File 'lib/roast/log.rb', line 61

def info(message)
  Roast::Event << { info: message }
end

#reset!Object

: () -> void



91
92
93
# File 'lib/roast/log.rb', line 91

def reset!
  @logger = nil
end

#tty?Boolean

: () -> bool

Returns:

  • (Boolean)


96
97
98
99
100
101
# File 'lib/roast/log.rb', line 96

def tty?
  return false unless @logger

  logdev = @logger.instance_variable_get(:@logdev)&.dev
  logdev&.respond_to?(:isatty) && logdev&.isatty
end

#unknown(message) ⇒ Object

: (String) -> void



81
82
83
# File 'lib/roast/log.rb', line 81

def unknown(message)
  Roast::Event << { unknown: message }
end

#warn(message) ⇒ Object

: (String) -> void



66
67
68
# File 'lib/roast/log.rb', line 66

def warn(message)
  Roast::Event << { warn: message }
end