Class: NullLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/null_logger.rb,
lib/null_logger/version.rb

Overview

Null logger class. This is essentially the same as sending data down the ‘/dev/null` black hole.

Examples:

Basic Usage


logger = NullLogger.new
Rails.logger = logger

Basic Pattern Usage

class SomeService
  def initialize(options = {})
    @logger = options[:logger] || NullLogger.new
  end

  def perform
    @logger.debug -> { "do some work here" }
    # .. ..
    @logger.info -> { "finished working" }
  end
end

service = SomeService.new(logger: Logger.new(STDOUT))
service.perform

silent = SomeService.new(logger: NullLogger.new
silent.perform

Constant Summary collapse

VERSION =

null-logger gem Version

'0.1.7'

Instance Method Summary collapse

Instance Method Details

#debug(*_args) ⇒ nil

Parameters:

  • _args

    Anything that we want to ignore

Returns:

  • (nil)


84
85
86
# File 'lib/null_logger.rb', line 84

def debug(*_args)
  nil
end

#debug?FALSE

Returns:

  • (FALSE)


89
90
91
# File 'lib/null_logger.rb', line 89

def debug?
  false
end

#error(*_args) ⇒ nil

Parameters:

  • _args

    Anything that we want to ignore

Returns:

  • (nil)


51
52
53
# File 'lib/null_logger.rb', line 51

def error(*_args)
  nil
end

#error?FALSE

Returns:

  • (FALSE)


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

def error?
  false
end

#fatal(*_args) ⇒ nil

Parameters:

  • _args

    Anything that we want to ignore

Returns:

  • (nil)


40
41
42
# File 'lib/null_logger.rb', line 40

def fatal(*_args)
  nil
end

#fatal?FALSE

Returns:

  • (FALSE)


45
46
47
# File 'lib/null_logger.rb', line 45

def fatal?
  false
end

#info(*_args) ⇒ nil

Parameters:

  • _args

    Anything that we want to ignore

Returns:

  • (nil)


73
74
75
# File 'lib/null_logger.rb', line 73

def info(*_args)
  nil
end

#info?FALSE

Returns:

  • (FALSE)


78
79
80
# File 'lib/null_logger.rb', line 78

def info?
  false
end

#unknown(*_args) ⇒ nil

Parameters:

  • _args

    Anything that we want to ignore

Returns:

  • (nil)


34
35
36
# File 'lib/null_logger.rb', line 34

def unknown(*_args)
  nil
end

#warn(*_args) ⇒ nil

Parameters:

  • _args

    Anything that we want to ignore

Returns:

  • (nil)


62
63
64
# File 'lib/null_logger.rb', line 62

def warn(*_args)
  nil
end

#warn?FALSE

Returns:

  • (FALSE)


67
68
69
# File 'lib/null_logger.rb', line 67

def warn?
  false
end