Module: Dronejob::Modules::Log
Constant Summary collapse
- COLOR_BOLD =
"\e[1m"- COLOR_RED =
"\e[31m"- COLOR_RED_BG =
"\e[41m"- COLOR_WHITE =
"\e[38;5;15m"- COLOR_GREY =
"\e[38;5;245m"- COLOR_GREY_BG =
"\e[48;5;255m"- COLOR_END =
"\e[0m"
Instance Method Summary collapse
- #alert(message) ⇒ Object
- #backtrace(lines) ⇒ Object
- #critical(message) ⇒ Object
- #debug(message) ⇒ Object
- #emergency(message) ⇒ Object
- #error(message) ⇒ Object
- #error!(message) ⇒ Object
- #info(message) ⇒ Object
- #log(level, message) ⇒ Object
- #notice(message) ⇒ Object
- #warning(message) ⇒ Object
Instance Method Details
#alert(message) ⇒ Object
115 116 117 |
# File 'lib/dronejob/modules/log.rb', line 115 def alert() log(:alert, ) end |
#backtrace(lines) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/dronejob/modules/log.rb', line 93 def backtrace(lines) lines.each do |line| line.gsub!("#{Dir.pwd}/", '') (file, lineno, info) = line.split(":") if %r{ruby/?gems}.match(line).nil? if log_stdout? log(:error, "#{COLOR_GREY_BG}#{COLOR_GREY} #{lineno.rjust(5, ' ')} #{COLOR_END} #{COLOR_RED}#{file}#{COLOR_END} #{COLOR_GREY}#{info}#{COLOR_END}") else log(:error, " - #{file}:#{lineno} #{info}") end end end end |
#critical(message) ⇒ Object
111 112 113 |
# File 'lib/dronejob/modules/log.rb', line 111 def critical() log(:critical, ) end |
#debug(message) ⇒ Object
60 61 62 |
# File 'lib/dronejob/modules/log.rb', line 60 def debug() log(:debug, ) end |
#emergency(message) ⇒ Object
119 120 121 |
# File 'lib/dronejob/modules/log.rb', line 119 def emergency() log(:emergency, ) end |
#error(message) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/dronejob/modules/log.rb', line 76 def error() if .kind_of?(StandardError) if option(:dronejob_log) == "google" log(:error, "#{.backtrace.first}: #{.} (#{.class})\n\t#{.backtrace.drop(1).join("\n\t")}") else if log_stdout? log(:error, "#{COLOR_RED_BG}#{COLOR_BOLD}#{COLOR_WHITE} ERROR #{COLOR_END} #{COLOR_BOLD}#{.class}: #{COLOR_RED}#{.}#{COLOR_END}") else log(:error, "[ERROR] #{.class}: #{.}") end backtrace(.backtrace) end else log(:error, ) end end |
#error!(message) ⇒ Object
107 108 109 |
# File 'lib/dronejob/modules/log.rb', line 107 def error!() throw end |
#info(message) ⇒ Object
64 65 66 |
# File 'lib/dronejob/modules/log.rb', line 64 def info() log(:info, ) end |
#log(level, message) ⇒ Object
56 57 58 |
# File 'lib/dronejob/modules/log.rb', line 56 def log(level, ) self.class.log(level, , self) end |
#notice(message) ⇒ Object
68 69 70 |
# File 'lib/dronejob/modules/log.rb', line 68 def notice() log(:notice, ) end |
#warning(message) ⇒ Object
72 73 74 |
# File 'lib/dronejob/modules/log.rb', line 72 def warning() log(:warning, ) end |