Class: Scarpe::Components::PrintLogImpl::PrintLogger

Inherits:
Object
  • Object
show all
Defined in:
scarpe-components/lib/scarpe/components/print_logger.rb

Constant Summary collapse

LEVELS =
{
  :never => 1000,
  :error => 4,
  :warn => 3,
  :info => 2,
  :debug => 1,
  :always => -1,
}

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component_name) ⇒ PrintLogger

Returns a new instance of PrintLogger.



27
28
29
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 27

def initialize(component_name)
  @comp_name = component_name
end

Class Attribute Details

.min_levelObject

Returns the value of attribute min_level.



14
15
16
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 14

def min_level
  @min_level
end

.silenceObject

Returns the value of attribute silence.



13
14
15
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 13

def silence
  @silence
end

Instance Method Details

#debug(msg) ⇒ Object



41
42
43
44
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 41

def debug(msg)
  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:debug]
  puts "#{@comp_name} debug: #{msg}" unless PrintLogger.silence
end

#error(msg) ⇒ Object



31
32
33
34
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 31

def error(msg)
  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:error]
  puts "#{@comp_name} error: #{msg}"
end

#info(msg) ⇒ Object



46
47
48
49
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 46

def info(msg)
  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:info]
  puts "#{@comp_name} info: #{msg}"
end

#warn(msg) ⇒ Object



36
37
38
39
# File 'scarpe-components/lib/scarpe/components/print_logger.rb', line 36

def warn(msg)
  return if PrintLogger.silence || PrintLogger.min_level > LEVELS[:warn]
  puts "#{@comp_name} warn: #{msg}" unless PrintLogger.silence
end