Class: Justimmo::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/justimmo/logger.rb

Overview

The Justimmo logger.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Logger

The main logger.


14
15
16
17
18
19
20
21
# File 'lib/justimmo/logger.rb', line 14

def initialize(config = nil)
  super(STDOUT)

  self.level = config&.debug? ? Logger::DEBUG : Logger::INFO
  self.formatter = proc do |severity, datetime, _progname, msg|
    "#{severity}  [#{datetime}]  #{msg}\n"
  end
end

Class Method Details

.configure(config = nil) ⇒ Logger

Configure the global logger.


28
29
30
# File 'lib/justimmo/logger.rb', line 28

def configure(config = nil)
  @logger = new(config)
end

.debug(*args) ⇒ Object

:nodoc:


32
33
34
# File 'lib/justimmo/logger.rb', line 32

def debug(*args) # :nodoc:
  @logger&.debug(*args)
end

.error(*args) ⇒ Object

:nodoc:


44
45
46
# File 'lib/justimmo/logger.rb', line 44

def error(*args) # :nodoc:
  @logger&.error(*args)
end

.info(*args) ⇒ Object

:nodoc


36
37
38
# File 'lib/justimmo/logger.rb', line 36

def info(*args) # :nodoc
  @logger&.info(*args)
end

.warn(*args) ⇒ Object

:nodoc:


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

def warn(*args) # :nodoc:
  @logger&.warn(*args)
end