Class: GreenLog::ClassicLogger

Inherits:
Object
  • Object
show all
Includes:
SeverityThresholdSupport
Defined in:
lib/green_log/classic_logger.rb

Overview

An alternative to ‘GreenLog::Logger` for older code, which implements the same interface as the built-in Ruby `::Logger`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SeverityThresholdSupport

#severity_threshold

Constructor Details

#initialize(downstream) ⇒ ClassicLogger

Returns a new instance of ClassicLogger.



14
15
16
# File 'lib/green_log/classic_logger.rb', line 14

def initialize(downstream)
  @downstream = downstream
end

Instance Attribute Details

#downstreamObject (readonly)

Returns the value of attribute downstream.



18
19
20
# File 'lib/green_log/classic_logger.rb', line 18

def downstream
  @downstream
end

Instance Method Details

#add(severity, message = :unspecified, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/green_log/classic_logger.rb', line 22

def add(severity, message = :unspecified, &block)
  severity = Integer(severity)
  return if severity < severity_threshold

  entry = Entry.build(severity, resolve_message(message, &block))

  downstream << entry

  true
end