Class: QuietQuality::Logger
- Inherits:
-
Object
- Object
- QuietQuality::Logger
- Defined in:
- lib/quiet_quality/logger.rb
Constant Summary collapse
- LEVEL_UPS =
{none: :warn, warn: :info, info: :debug}.freeze
- LEVELS =
{none: 0, warn: 1, info: 2, debug: 3}.freeze
- COLORS =
{warn: :yellow, info: :light_blue, debug: :light_cyan}.freeze
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
Instance Method Summary collapse
- #debug(message, data: nil) ⇒ Object
- #increase_level! ⇒ Object
- #info(message, data: nil) ⇒ Object
-
#initialize(level: :warn, stream: $stderr) ⇒ Logger
constructor
A new instance of Logger.
- #show?(message_level) ⇒ Boolean
- #warn(message, data: nil) ⇒ Object
Constructor Details
#initialize(level: :warn, stream: $stderr) ⇒ Logger
Returns a new instance of Logger.
7 8 9 10 |
# File 'lib/quiet_quality/logger.rb', line 7 def initialize(level: :warn, stream: $stderr) @level = level @stream = stream end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
12 13 14 |
# File 'lib/quiet_quality/logger.rb', line 12 def level @level end |
Instance Method Details
#debug(message, data: nil) ⇒ Object
36 37 38 |
# File 'lib/quiet_quality/logger.rb', line 36 def debug(, data: nil) (, data, :debug) end |
#increase_level! ⇒ Object
14 15 16 17 |
# File 'lib/quiet_quality/logger.rb', line 14 def increase_level! next_level = LEVEL_UPS.fetch(level, nil) self.level = next_level if next_level end |
#info(message, data: nil) ⇒ Object
32 33 34 |
# File 'lib/quiet_quality/logger.rb', line 32 def info(, data: nil) (, data, :info) end |
#show?(message_level) ⇒ Boolean
19 20 21 |
# File 'lib/quiet_quality/logger.rb', line 19 def show?() LEVELS[] <= LEVELS[level] end |
#warn(message, data: nil) ⇒ Object
28 29 30 |
# File 'lib/quiet_quality/logger.rb', line 28 def warn(, data: nil) (, data, :warn) end |