Class: Regent::Logger
- Inherits:
-
Object
- Object
- Regent::Logger
- Defined in:
- lib/regent/logger.rb
Constant Summary collapse
- COLORS =
%i[dim white green yellow red blue cyan clear].freeze
Instance Attribute Summary collapse
-
#nested_spinner ⇒ Object
readonly
Returns the value of attribute nested_spinner.
-
#spinner ⇒ Object
readonly
Returns the value of attribute spinner.
Class Method Summary collapse
Instance Method Summary collapse
- #error(**args) ⇒ Object
- #info(label:, message:, duration: nil, type: nil, meta: nil, top_level: false) ⇒ Object
-
#initialize(output: $stdout) ⇒ Logger
constructor
A new instance of Logger.
- #start(**args) ⇒ Object
- #success(**args) ⇒ Object
Constructor Details
#initialize(output: $stdout) ⇒ Logger
Returns a new instance of Logger.
14 15 16 17 18 |
# File 'lib/regent/logger.rb', line 14 def initialize(output: $stdout) @pastel = Pastel.new @spinner = build_spinner(spinner_symbol, output) @nested_spinner = build_spinner("#{dim(" ├──")}#{spinner_symbol}", output) end |
Instance Attribute Details
#nested_spinner ⇒ Object (readonly)
Returns the value of attribute nested_spinner.
20 21 22 |
# File 'lib/regent/logger.rb', line 20 def nested_spinner @nested_spinner end |
#spinner ⇒ Object (readonly)
Returns the value of attribute spinner.
20 21 22 |
# File 'lib/regent/logger.rb', line 20 def spinner @spinner end |
Class Method Details
.warn_and_exit(message) ⇒ Object
8 9 10 11 |
# File 'lib/regent/logger.rb', line 8 def warn_and_exit() warn exit 1 end |
Instance Method Details
#error(**args) ⇒ Object
36 37 38 |
# File 'lib/regent/logger.rb', line 36 def error(**args) info(**args).error end |
#info(label:, message:, duration: nil, type: nil, meta: nil, top_level: false) ⇒ Object
22 23 24 25 26 |
# File 'lib/regent/logger.rb', line 22 def info(label:, message:, duration: nil, type: nil, meta: nil, top_level: false) current_spinner = top_level ? spinner : nested_spinner current_spinner.update(title: (label, , duration, type, )) current_spinner end |
#start(**args) ⇒ Object
28 29 30 |
# File 'lib/regent/logger.rb', line 28 def start(**args) info(**args).auto_spin end |
#success(**args) ⇒ Object
32 33 34 |
# File 'lib/regent/logger.rb', line 32 def success(**args) info(**args).success end |