Class: Scarpe::Components::PrintLogImpl::PrintLogger
- Inherits:
-
Object
- Object
- Scarpe::Components::PrintLogImpl::PrintLogger
- Defined in:
- 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
-
.min_level ⇒ Object
Returns the value of attribute min_level.
-
.silence ⇒ Object
Returns the value of attribute silence.
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(component_name) ⇒ PrintLogger
constructor
A new instance of PrintLogger.
- #warn(msg) ⇒ Object
Constructor Details
#initialize(component_name) ⇒ PrintLogger
Returns a new instance of PrintLogger.
27 28 29 |
# File 'lib/scarpe/components/print_logger.rb', line 27 def initialize(component_name) @comp_name = component_name end |
Class Attribute Details
.min_level ⇒ Object
Returns the value of attribute min_level.
14 15 16 |
# File 'lib/scarpe/components/print_logger.rb', line 14 def min_level @min_level end |
.silence ⇒ Object
Returns the value of attribute silence.
13 14 15 |
# File 'lib/scarpe/components/print_logger.rb', line 13 def silence @silence end |
Instance Method Details
#debug(msg) ⇒ Object
41 42 43 44 |
# File '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 '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 '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 '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 |