Class: SimpleLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_checks/simple_logger.rb

Constant Summary collapse

LOG_LEVELS =
[:debug, :info, :warn, :error, :fatal, :unknown].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_level: :debug) ⇒ SimpleLogger

Returns a new instance of SimpleLogger.



6
7
8
# File 'lib/gem_checks/simple_logger.rb', line 6

def initialize(default_level: :debug)
  @level = LOG_LEVELS.index(default_level)
end

Instance Attribute Details

#level=(value) ⇒ Object (writeonly)

Sets the attribute level

Parameters:

  • value

    the value to set the attribute level to.



2
3
4
# File 'lib/gem_checks/simple_logger.rb', line 2

def level=(value)
  @level = value
end

Instance Method Details

#debugObject



10
11
12
# File 'lib/gem_checks/simple_logger.rb', line 10

def debug(*)
  log_if_level_valid(:debug)
end

#errorObject



22
23
24
# File 'lib/gem_checks/simple_logger.rb', line 22

def error(*)
  log_level_if_valid(:error)
end

#fatalObject



26
27
28
# File 'lib/gem_checks/simple_logger.rb', line 26

def fatal(*)
  log_level_if_valid(:fatal)
end

#infoObject



14
15
16
# File 'lib/gem_checks/simple_logger.rb', line 14

def info(*)
  log_if_level_valid(:info)
end

#unknownObject



30
31
32
# File 'lib/gem_checks/simple_logger.rb', line 30

def unknown(*)
  log_level_if_valid(:unknown)
end

#warnObject



18
19
20
# File 'lib/gem_checks/simple_logger.rb', line 18

def warn(*)
  log_if_level_valid(:warn)
end