Class: RightSupport::Log::NullLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/right_support/log/null_logger.rb

Overview

A logger than does not perform any logging. This is useful to send log entries to “the bit bucket” or “to /dev/null” – hence the name.

Instance Method Summary collapse

Constructor Details

#initializeNullLogger

Initialize a new instance of this class.



31
32
33
# File 'lib/right_support/log/null_logger.rb', line 31

def initialize
  super(nil)
end

Instance Method Details

#<<(msg) ⇒ Object

Do nothing. This method exists for interface compatibility with Logger.

Parameters

msg(String)

the message to log, or nil

Block

If message == nil and a block is given, yields to the block. The block’s output value is ignored.

Return



64
65
66
# File 'lib/right_support/log/null_logger.rb', line 64

def <<(msg)
  msg.to_s.size
end

#add(severity, message = nil, progname = nil, &block) ⇒ Object

Do nothing. This method exists for interface compatibility with Logger.

Parameters

severity(Integer)

one of the Logger severity constants

message(String)

the message to log, or nil

progname(String)

the program name, or nil

Block

If message == nil and a block is given, yields to the block. The block’s output value is ignored.

Return

always returns true



48
49
50
51
52
# File 'lib/right_support/log/null_logger.rb', line 48

def add(severity, message = nil, progname = nil, &block)
  #act like a real Logger w/r/t the block
  yield if message.nil? && block_given?
  true
end

#closeObject

Do nothing. This method exists for interface compatibility with Logger.

Return

always returns true



72
73
74
# File 'lib/right_support/log/null_logger.rb', line 72

def close
  nil
end