Module: Simple::CLI::Logger::ColoredLogger
- Extended by:
- ColoredLogger
- Included in:
- ColoredLogger
- Defined in:
- lib/simple/cli/logger/colored_logger.rb
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.
12 13 14 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 12 def level @level end |
Instance Method Details
#debug(*args, &block) ⇒ Object
46 47 48 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 46 def debug(*args, &block) log :debug, *args, &block end |
#debug? ⇒ Boolean
71 72 73 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 71 def debug? level <= REQUIRED_LOG_LEVELS[:debug] end |
#error(*args, &block) ⇒ Object
58 59 60 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 58 def error(*args, &block) log :error, *args, &block end |
#error? ⇒ Boolean
83 84 85 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 83 def error? level <= REQUIRED_LOG_LEVELS[:error] end |
#fatal(*args, &block) ⇒ Object
62 63 64 65 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 62 def fatal(*args, &block) log :error, *args, &block exit 1 end |
#info(*args, &block) ⇒ Object
50 51 52 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 50 def info(*args, &block) log :info, *args, &block end |
#info? ⇒ Boolean
75 76 77 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 75 def info? level <= REQUIRED_LOG_LEVELS[:info] end |
#success(*args, &block) ⇒ Object
67 68 69 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 67 def success(*args, &block) log :success, *args, &block end |
#warn(*args, &block) ⇒ Object
54 55 56 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 54 def warn(*args, &block) log :warn, *args, &block end |
#warn? ⇒ Boolean
79 80 81 |
# File 'lib/simple/cli/logger/colored_logger.rb', line 79 def warn? level <= REQUIRED_LOG_LEVELS[:warn] end |