Class: Racket::Utils::Application::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/utils/application/logger.rb

Overview

Class for logging messages in the application.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, mode) ⇒ Logger

Returns a new instance of Logger.



36
37
38
39
# File 'lib/racket/utils/application/logger.rb', line 36

def initialize(logger, mode)
  @logger = logger
  @in_dev_mode = (mode == :dev)
end

Class Method Details

.service(_options = {}) ⇒ Proc

Returns a service proc that can be used by the registry.

Parameters:

  • _options (Hash) (defaults to: {})

    (unused)

Returns:

  • (Proc)


29
30
31
32
33
34
# File 'lib/racket/utils/application/logger.rb', line 29

def self.service(_options = {})
  lambda do |reg|
    settings = reg.application_settings
    new(settings.logger, settings.mode)
  end
end

Instance Method Details

#inform_all(message, level = :info) ⇒ Object

Sends a message to the logger.

Parameters:

  • message (String)
  • level (Symbol) (defaults to: :info)

Returns:

  • nil



46
47
48
# File 'lib/racket/utils/application/logger.rb', line 46

def inform_all(message, level = :info)
  inform(message, level)
end

#inform_dev(message, level = :debug) ⇒ Object

Sends a message to the logger, but only if we are running in dev mode.

Parameters:

  • message (String)
  • level (Symbol) (defaults to: :debug)

Returns:

  • nil



55
56
57
# File 'lib/racket/utils/application/logger.rb', line 55

def inform_dev(message, level = :debug)
  (inform(message, level) if @in_dev_mode) && nil
end