Module: CodeownerValidator::Logging
- Included in:
- Command, Tasks::Base
- Defined in:
- lib/codeowner_validator/common/logging.rb
Overview
Public: Mixin for adding methods needed for logging directly to the stdout
Instance Method Summary collapse
-
#log_command(*messages) ⇒ Object
Public: Displays the command message to the console.
-
#log_error(*messages) ⇒ Object
Public: Displays an error message to the console.
-
#log_info(*messages) ⇒ Object
Public: Displays an informational message to the console.
-
#log_stderr(*args) ⇒ Object
Public: Displays the stderr output to the console.
-
#log_verbose(*messages) ⇒ Object
Public: Designation if to show verbose output.
-
#log_warn(*messages) ⇒ Object
Public: Displays a warning message to the console.
-
#logger ⇒ Object
Internal: Reader for the logger attribute.
-
#program_name ⇒ Object
Public: Displays the current program running name.
Instance Method Details
#log_command(*messages) ⇒ Object
Public: Displays the command message to the console
29 30 31 32 33 |
# File 'lib/codeowner_validator/common/logging.rb', line 29 def log_command(*) .flatten.each do || logger.info Rainbow().bright end end |
#log_error(*messages) ⇒ Object
Public: Displays an error message to the console
50 51 52 53 54 |
# File 'lib/codeowner_validator/common/logging.rb', line 50 def log_error(*) .flatten.each do || logger.error Rainbow().red.bold end end |
#log_info(*messages) ⇒ Object
Public: Displays an informational message to the console
36 37 38 39 40 |
# File 'lib/codeowner_validator/common/logging.rb', line 36 def log_info(*) .flatten.each do || logger.info Rainbow().blue.bright end end |
#log_stderr(*args) ⇒ Object
Public: Displays the stderr output to the console
57 58 59 60 61 |
# File 'lib/codeowner_validator/common/logging.rb', line 57 def log_stderr(*args) args.each do || logger.error end end |
#log_verbose(*messages) ⇒ Object
Public: Designation if to show verbose output
20 21 22 23 24 25 26 |
# File 'lib/codeowner_validator/common/logging.rb', line 20 def log_verbose(*) return unless verbose? .flatten.each do || logger.info Rainbow( || yield).magenta.bright end end |
#log_warn(*messages) ⇒ Object
Public: Displays a warning message to the console
43 44 45 46 47 |
# File 'lib/codeowner_validator/common/logging.rb', line 43 def log_warn(*) .flatten.each do || logger.warn Rainbow().yellow end end |
#logger ⇒ Object
Internal: Reader for the logger attribute.
Returns a Logger instance.
12 13 14 15 16 17 |
# File 'lib/codeowner_validator/common/logging.rb', line 12 def logger return @logger if @logger # depending of the context, utilize existing rails logger if exists @logger = rails_logger || default_logger end |
#program_name ⇒ Object
Public: Displays the current program running name
64 65 66 |
# File 'lib/codeowner_validator/common/logging.rb', line 64 def program_name @program_name ||= File.basename($PROGRAM_NAME) end |