Class: Ductr::Log::StandardOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/ductr/log/outputs/standard_output.rb

Overview

The STDOUT logger output

Direct Known Subclasses

FileOutput

Constant Summary collapse

SEVERITY_LABELS =

Returns The labels to associate to severity integers.

Returns:

  • (Array<String>)

    The labels to associate to severity integers

%w[DEBUG INFO WARN ERROR FATAL ANY].freeze

Instance Method Summary collapse

Constructor Details

#initialize(formatter, **options) ⇒ StandardOutput

Creates a logger output instance

Parameters:

  • formatter (::Logger::Formatter)

    The formatter to use to write the logs in STDOUT

  • **options (Hash)

    The LogDevice options



20
21
22
23
# File 'lib/ductr/log/outputs/standard_output.rb', line 20

def initialize(formatter, **options)
  @formatter = formatter.new
  @log_device = ::Logger::LogDevice.new $stdout, **options
end

Instance Method Details

#write(severity, prog_name, message) ⇒ void

This method returns an undefined value.

Writes the log to the STDOUT

Parameters:

  • severity (Integer)

    The log’s severity level

  • prog_name (Symbol)

    The “program” name, used to add job method name to the log

  • message (String)

    The log message



34
35
36
# File 'lib/ductr/log/outputs/standard_output.rb', line 34

def write(severity, prog_name, message)
  @log_device.write @formatter.call(SEVERITY_LABELS[severity], Time.now, prog_name, message)
end