Module: Log
- Defined in:
- lib/rbbt/util/log.rb
Constant Summary collapse
- DEBUG =
0
- LOW =
1
- MEDIUM =
2
- HIGH =
3
- INFO =
4
- WARN =
5
- ERROR =
6
- SEVERITY_COLOR =
def self.severity
@severity
end
["0;37m", "0;32m", "0;33m", "0;31m", "1;0m" ].collect{|e| "\033[#{e}"}
Class Attribute Summary collapse
-
.logfile ⇒ Object
Returns the value of attribute logfile.
-
.severity ⇒ Object
Returns the value of attribute severity.
Class Method Summary collapse
- .debug(message) ⇒ Object
- .error(message) ⇒ Object
- .high(message) ⇒ Object
- .info(message) ⇒ Object
- .log(message, severity = MEDIUM) ⇒ Object
- .low(message) ⇒ Object
- .medium(message) ⇒ Object
- .warn(message) ⇒ Object
Class Attribute Details
.logfile ⇒ Object
Returns the value of attribute logfile.
12 13 14 |
# File 'lib/rbbt/util/log.rb', line 12 def logfile @logfile end |
.severity ⇒ Object
Returns the value of attribute severity.
12 13 14 |
# File 'lib/rbbt/util/log.rb', line 12 def severity @severity end |
Class Method Details
.debug(message) ⇒ Object
42 43 44 |
# File 'lib/rbbt/util/log.rb', line 42 def self.debug() log(, DEBUG) end |
.error(message) ⇒ Object
66 67 68 |
# File 'lib/rbbt/util/log.rb', line 66 def self.error() log(, ERROR) end |
.high(message) ⇒ Object
54 55 56 |
# File 'lib/rbbt/util/log.rb', line 54 def self.high() log(, HIGH) end |
.info(message) ⇒ Object
58 59 60 |
# File 'lib/rbbt/util/log.rb', line 58 def self.info() log(, INFO) end |
.log(message, severity = MEDIUM) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rbbt/util/log.rb', line 30 def self.log(, severity = MEDIUM) ||= "" severity_color = SEVERITY_COLOR[severity] font_color = {false => "\033[0;37m", true => "\033[0m"}[severity >= INFO] if severity >= self.severity and not .empty? str = "\033[0;37m#{Time.now.strftime("[%m/%d/%y-%H:%M:%S]")}#{severity_color}[#{severity.to_s}]\033[0m:#{font_color} " << .strip << "\033[0m" STDERR.puts str logfile.puts str unless logfile.nil? end end |
.low(message) ⇒ Object
46 47 48 |
# File 'lib/rbbt/util/log.rb', line 46 def self.low() log(, LOW) end |
.medium(message) ⇒ Object
50 51 52 |
# File 'lib/rbbt/util/log.rb', line 50 def self.medium() log(, MEDIUM) end |
.warn(message) ⇒ Object
62 63 64 |
# File 'lib/rbbt/util/log.rb', line 62 def self.warn() log(, WARN) end |