Class: Nvoi::Utils::Logger
- Inherits:
-
Object
- Object
- Nvoi::Utils::Logger
- Defined in:
- lib/nvoi/utils/logger.rb
Constant Summary collapse
- COLORS =
{ reset: "\e[0m", red: "\e[31m", green: "\e[32m", yellow: "\e[33m", blue: "\e[34m", magenta: "\e[35m", cyan: "\e[36m", white: "\e[37m", bold: "\e[1m" }.freeze
Instance Method Summary collapse
- #blank ⇒ Object
- #debug(message, *args) ⇒ Object
- #error(message, *args) ⇒ Object
- #info(message, *args) ⇒ Object
-
#initialize(output: $stdout, color: true) ⇒ Logger
constructor
A new instance of Logger.
-
#ok(message, *args) ⇒ Object
OK indicator for step completion.
- #separator ⇒ Object
-
#step(message, *args) ⇒ Object
Step indicator for multi-step operations.
- #success(message, *args) ⇒ Object
- #warning(message, *args) ⇒ Object
Constructor Details
#initialize(output: $stdout, color: true) ⇒ Logger
Returns a new instance of Logger.
18 19 20 21 |
# File 'lib/nvoi/utils/logger.rb', line 18 def initialize(output: $stdout, color: true) @output = output @color = color && output.tty? end |
Instance Method Details
#blank ⇒ Object
59 60 61 |
# File 'lib/nvoi/utils/logger.rb', line 59 def blank @output.puts end |
#debug(message, *args) ⇒ Object
39 40 41 42 43 |
# File 'lib/nvoi/utils/logger.rb', line 39 def debug(, *args) return unless ENV["NVOI_DEBUG"] log(:magenta, "DEBUG", (, args)) end |
#error(message, *args) ⇒ Object
35 36 37 |
# File 'lib/nvoi/utils/logger.rb', line 35 def error(, *args) log(:red, "ERROR", (, args)) end |
#info(message, *args) ⇒ Object
23 24 25 |
# File 'lib/nvoi/utils/logger.rb', line 23 def info(, *args) log(:blue, "INFO", (, args)) end |
#ok(message, *args) ⇒ Object
OK indicator for step completion
51 52 53 |
# File 'lib/nvoi/utils/logger.rb', line 51 def ok(, *args) log(:green, "OK", (, args)) end |
#separator ⇒ Object
55 56 57 |
# File 'lib/nvoi/utils/logger.rb', line 55 def separator @output.puts colorize(:cyan, "-" * 60) end |
#step(message, *args) ⇒ Object
Step indicator for multi-step operations
46 47 48 |
# File 'lib/nvoi/utils/logger.rb', line 46 def step(, *args) log(:cyan, "STEP", (, args)) end |
#success(message, *args) ⇒ Object
27 28 29 |
# File 'lib/nvoi/utils/logger.rb', line 27 def success(, *args) log(:green, "SUCCESS", (, args)) end |
#warning(message, *args) ⇒ Object
31 32 33 |
# File 'lib/nvoi/utils/logger.rb', line 31 def warning(, *args) log(:yellow, "WARNING", (, args)) end |