Module: AppArchetype::Logger
- Included in:
- Renderer
- Defined in:
- lib/app_archetype/logger.rb
Overview
CLI Logging methods
Instance Method Summary collapse
-
#logger(out = STDOUT) ⇒ ::Logger
Creates logger for printing messages.
-
#print_error(message) ⇒ Object
Prints error to STDERR.
-
#print_message(message) ⇒ Object
Prints command line message to STDOUT.
-
#print_message_and_exit(message, exit_code = 1) ⇒ Object
Prints a message and then exits with given status code.
-
#print_warning(message) ⇒ Object
Prints warning to STDOUT.
Instance Method Details
#logger(out = STDOUT) ⇒ ::Logger
Creates logger for printing messages
Sets the formatter to output only the provided message to the specified IO
14 15 16 17 18 19 20 21 |
# File 'lib/app_archetype/logger.rb', line 14 def logger(out = STDOUT) @logger ||= ::Logger.new(out) @logger.formatter = proc do |_sev, _time, _prog, msg| "#{msg}\n" end @logger end |
#print_error(message) ⇒ Object
Prints error to STDERR
For indicating fatal message to user
52 53 54 |
# File 'lib/app_archetype/logger.rb', line 52 def print_error() logger(STDERR).error() end |
#print_message(message) ⇒ Object
Prints command line message to STDOUT
For use when printing info messages for a user to STDOUT
30 31 32 |
# File 'lib/app_archetype/logger.rb', line 30 def () logger.info() end |
#print_message_and_exit(message, exit_code = 1) ⇒ Object
Prints a message and then exits with given status code
This will terminate the program with the given status code
64 65 66 67 |
# File 'lib/app_archetype/logger.rb', line 64 def (, exit_code = 1) () exit(exit_code) end |
#print_warning(message) ⇒ Object
Prints warning to STDOUT
For use when printing warn messages to STDOUT
41 42 43 |
# File 'lib/app_archetype/logger.rb', line 41 def print_warning() logger.warn() end |