Class: ProMotion::Logger
- Inherits:
-
Object
- Object
- ProMotion::Logger
- Defined in:
- lib/ProMotion/logger/logger.rb
Constant Summary collapse
- NAME =
"ProMotion::Logger: "
- COLORS =
{ default: [ '', '' ], red: [ "\e[0;31m", "\e[0m" ], green: [ "\e[0;32m", "\e[0m" ], yellow: [ "\e[0;33m", "\e[0m" ], blue: [ "\e[0;34m", "\e[0m" ], purple: [ "\e[0;35m", "\e[0m" ], cyan: [ "\e[0;36m", "\e[0m" ] }
- LEVELS =
{ off: [], error: [:error], warn: [:error, :warn], info: [:error, :warn, :info], debug: [:error, :warn, :info, :debug], verbose: [:error, :warn, :info, :debug, :verbose], }
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #deprecated(message) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
- #levels ⇒ Object
-
#log(label, message_text, color) ⇒ Object
Usage: PM.logger.log(“ERROR”, “message here”, :red).
- #warn(message) ⇒ Object
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
3 4 5 |
# File 'lib/ProMotion/logger/logger.rb', line 3 def level @level end |
Instance Method Details
#debug(message) ⇒ Object
59 60 61 |
# File 'lib/ProMotion/logger/logger.rb', line 59 def debug() log('DEBUG', , :purple) if self.levels.include?(:debug) end |
#deprecated(message) ⇒ Object
51 52 53 |
# File 'lib/ProMotion/logger/logger.rb', line 51 def deprecated() log('DEPRECATED', , :yellow) if self.levels.include?(:warn) end |
#error(message) ⇒ Object
47 48 49 |
# File 'lib/ProMotion/logger/logger.rb', line 47 def error() log('ERROR', , :red) if self.levels.include?(:error) end |
#info(message) ⇒ Object
63 64 65 |
# File 'lib/ProMotion/logger/logger.rb', line 63 def info() log('INFO', , :green) if self.levels.include?(:info) end |
#levels ⇒ Object
35 36 37 |
# File 'lib/ProMotion/logger/logger.rb', line 35 def levels LEVELS[self.level] || [] end |
#log(label, message_text, color) ⇒ Object
Usage: PM.logger.log(“ERROR”, “message here”, :red)
40 41 42 43 44 45 |
# File 'lib/ProMotion/logger/logger.rb', line 40 def log(label, , color) # return if defined?(RUBYMOTION_ENV) && RUBYMOTION_ENV == "test" color = COLORS[color] || COLORS[:default] $stderr.puts color[0] + NAME + "[#{label}] #{}" + color[1] nil end |
#warn(message) ⇒ Object
55 56 57 |
# File 'lib/ProMotion/logger/logger.rb', line 55 def warn() log('WARN', , :yellow) if self.levels.include?(:warn) end |