Class: Getch::Log
- Inherits:
-
Object
- Object
- Getch::Log
- Defined in:
- lib/getch/log.rb
Overview
Display message to stdout and write in a log file.
Constant Summary collapse
- WHITE =
"\033[37m"- CYAN =
"\033[36m"- MAGENTA =
"\033[35m"- BLUE =
"\033[34m"- YELLOW =
"\033[33m"- GREEN =
"\033[32m"- RED =
"\033[31m"- BLACK =
"\033[30m"- BOLD =
"\033[1m"- CLEAR =
"\033[0m"
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
-
#info(msg) ⇒ Object
TODO, remove length.
-
#initialize(verbose: false) ⇒ Log
constructor
A new instance of Log.
- #result_ok ⇒ Object
Constructor Details
#initialize(verbose: false) ⇒ Log
Returns a new instance of Log.
19 20 21 22 23 |
# File 'lib/getch/log.rb', line 19 def initialize(verbose: false) @log_file = '/tmp/log_install.txt' @verbose = verbose init end |
Instance Method Details
#debug(msg) ⇒ Object
42 43 44 45 |
# File 'lib/getch/log.rb', line 42 def debug(msg) @debug.debug "#{BOLD} > #{CLEAR}#{WHITE}#{msg}#{CLEAR}" @save.debug(msg) end |
#error(msg) ⇒ Object
37 38 39 40 |
# File 'lib/getch/log.rb', line 37 def error(msg) @error.error "#{BOLD} > #{CLEAR}#{WHITE}#{msg}#{CLEAR}" @save.error(msg) end |
#fatal(msg) ⇒ Object
47 48 49 50 51 |
# File 'lib/getch/log.rb', line 47 def fatal(msg) @fatal.fatal "#{BOLD} > #{CLEAR}#{WHITE}#{msg}#{CLEAR}\n" @save.fatal(msg) exit 1 end |
#info(msg) ⇒ Object
TODO, remove length
26 27 28 29 30 31 |
# File 'lib/getch/log.rb', line 26 def info(msg) tab = msg.match("\n") ? '' : add_tab(msg) l = msg.length @info.info "#{GREEN}#{BOLD} >>> #{CLEAR}#{l} #{WHITE}#{msg}#{CLEAR}" + tab @save.info(msg) end |
#result_ok ⇒ Object
33 34 35 |
# File 'lib/getch/log.rb', line 33 def result_ok @result.info "#{GREEN}[ #{WHITE}ok#{GREEN} ]#{CLEAR}\n" end |