Module: Simple::CLI::Logger::ColoredLogger
- Extended by:
- ColoredLogger
- Included in:
- ColoredLogger
- Defined in:
- lib/simple/cli/logger/colored_logger.rb
Overview
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ModuleLength rubocop:disable Metrics/AbcSize 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.
10 11 12 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 10 def level @level end |
Instance Method Details
#debug(*args, &block) ⇒ Object
44 45 46 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 44 def debug(*args, &block) log :debug, *args, &block end |
#debug? ⇒ Boolean
69 70 71 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 69 def debug? level <= REQUIRED_LOG_LEVELS[:debug] end |
#error(*args, &block) ⇒ Object
56 57 58 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 56 def error(*args, &block) log :error, *args, &block end |
#error? ⇒ Boolean
81 82 83 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 81 def error? level <= REQUIRED_LOG_LEVELS[:error] end |
#fatal(*args, &block) ⇒ Object
60 61 62 63 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 60 def fatal(*args, &block) log :error, *args, &block exit 1 end |
#info(*args, &block) ⇒ Object
48 49 50 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 48 def info(*args, &block) log :info, *args, &block end |
#info? ⇒ Boolean
73 74 75 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 73 def info? level <= REQUIRED_LOG_LEVELS[:info] end |
#success(*args, &block) ⇒ Object
65 66 67 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 65 def success(*args, &block) log :success, *args, &block end |
#warn(*args, &block) ⇒ Object
52 53 54 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 52 def warn(*args, &block) log :warn, *args, &block end |
#warn? ⇒ Boolean
77 78 79 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 77 def warn? level <= REQUIRED_LOG_LEVELS[:warn] end |