Module: Simple::CLI::Logger::ColoredLogger
- Extended by:
- ColoredLogger
- Included in:
- ColoredLogger
- Defined in:
- lib/simple/cli/logger/colored_logger.rb
Overview
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
Constant Summary collapse
- COLORS =
{ clear: "\e[0m", # Embed in a String to clear all previous ANSI sequences. bold: "\e[1m", # The start of an ANSI bold sequence. black: "\e[30m", # Set the terminal's foreground ANSI color to black. red: "\e[31m", # Set the terminal's foreground ANSI color to red. green: "\e[32m", # Set the terminal's foreground ANSI color to green. yellow: "\e[33m", # Set the terminal's foreground ANSI color to yellow. blue: "\e[34m", # Set the terminal's foreground ANSI color to blue. magenta: "\e[35m", # Set the terminal's foreground ANSI color to magenta. cyan: "\e[36m", # Set the terminal's foreground ANSI color to cyan. white: "\e[37m", # Set the terminal's foreground ANSI color to white. on_black: "\e[40m", # Set the terminal's background ANSI color to black. on_red: "\e[41m", # Set the terminal's background ANSI color to red. on_green: "\e[42m", # Set the terminal's background ANSI color to green. on_yellow: "\e[43m", # Set the terminal's background ANSI color to yellow. on_blue: "\e[44m", # Set the terminal's background ANSI color to blue. on_magenta: "\e[45m", # Set the terminal's background ANSI color to magenta. on_cyan: "\e[46m", # Set the terminal's background ANSI color to cyan. on_white: "\e[47m" # Set the terminal's background ANSI color to white. }
- MESSAGE_COLOR =
{ info: :cyan, warn: :yellow, error: :red, success: :green, }
- @@started_at =
rubocop:disable Style/ClassVars
Time.now
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
Instance Method Summary collapse
- #debug(*args, &block) ⇒ Object
- #debug? ⇒ Boolean
- #error(*args, &block) ⇒ Object
- #error? ⇒ Boolean
- #fatal(*args, &block) ⇒ Object
- #info(*args, &block) ⇒ Object
- #info? ⇒ Boolean
- #success(*args, &block) ⇒ Object
- #warn(*args, &block) ⇒ Object
- #warn? ⇒ Boolean
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
9 10 11 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 9 def level @level end |
Instance Method Details
#debug(*args, &block) ⇒ Object
43 44 45 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 43 def debug(*args, &block) log :debug, *args, &block end |
#debug? ⇒ Boolean
68 69 70 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 68 def debug? level <= REQUIRED_LOG_LEVELS[:debug] end |
#error(*args, &block) ⇒ Object
55 56 57 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 55 def error(*args, &block) log :error, *args, &block end |
#error? ⇒ Boolean
80 81 82 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 80 def error? level <= REQUIRED_LOG_LEVELS[:error] end |
#fatal(*args, &block) ⇒ Object
59 60 61 62 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 59 def fatal(*args, &block) log :error, *args, &block exit 1 end |
#info(*args, &block) ⇒ Object
47 48 49 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 47 def info(*args, &block) log :info, *args, &block end |
#info? ⇒ Boolean
72 73 74 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 72 def info? level <= REQUIRED_LOG_LEVELS[:info] end |
#success(*args, &block) ⇒ Object
64 65 66 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 64 def success(*args, &block) log :success, *args, &block end |
#warn(*args, &block) ⇒ Object
51 52 53 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 51 def warn(*args, &block) log :warn, *args, &block end |
#warn? ⇒ Boolean
76 77 78 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 76 def warn? level <= REQUIRED_LOG_LEVELS[:warn] end |