Module: Verifly::HasLogger

Included in:
DependentCallbacks
Defined in:
lib/verifly/has_logger.rb

Overview

Mixin with logger attr_accessor and default value for it

Defined Under Namespace

Classes: NullLogger

Instance Attribute Summary collapse

Instance Attribute Details

#logger::Logger

Returns logger to be used within target module.

Returns:

  • (::Logger)

    logger to be used within target module



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/verifly/has_logger.rb', line 9

module HasLogger
  # Does nothing, provides ::Logger api
  class NullLogger < ::Logger
    # @api stdlib
    def initialize
      super(nil)
    end

    # @api stdlib
    # Logs nothing
    def add(*); end
  end

  attr_writer :logger

  def logger
    @logger ||= NullLogger.new
  end
end