Module: Rulp::Logger
- Defined in:
- lib/helpers/log.rb
Constant Summary collapse
- DEBUG =
5- INFO =
4- WARN =
3- ERROR =
2- OFF =
1- LEVELS =
{ debug: DEBUG, info: INFO, warn: WARN, error: ERROR, off: OFF }
Class Method Summary collapse
- .colorize(level) ⇒ Object
- .level ⇒ Object
- .level=(value) ⇒ Object
- .log(level, message) ⇒ Object
- .print_solver_outputs ⇒ Object
- .print_solver_outputs=(value) ⇒ Object
Class Method Details
.colorize(level) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/helpers/log.rb', line 51 def self.colorize(level) if defined?(Pry) && Pry.color case level.to_sym when :debug Pry::Helpers::Text.cyan(level) when :info Pry::Helpers::Text.green(level) when :warn Pry::Helpers::Text.magenta(level) when :error Pry::Helpers::Text.red(level) end else level end end |
.level ⇒ Object
33 34 35 |
# File 'lib/helpers/log.rb', line 33 def self.level @@level || :info end |
.level=(value) ⇒ Object
28 29 30 31 |
# File 'lib/helpers/log.rb', line 28 def self.level=(value) raise StandardError.new("#{value} is not a valid log level") unless LEVELS[value] @@level = value end |
.log(level, message) ⇒ Object
45 46 47 48 49 |
# File 'lib/helpers/log.rb', line 45 def self.log(level, ) if(LEVELS[level].to_i <= LEVELS[self.level]) puts("[#{colorize(level)}] #{message}") end end |
.print_solver_outputs ⇒ Object
37 38 39 |
# File 'lib/helpers/log.rb', line 37 def self.print_solver_outputs @@solver_level end |
.print_solver_outputs=(value) ⇒ Object
41 42 43 |
# File 'lib/helpers/log.rb', line 41 def self.print_solver_outputs=(value) @@solver_level = value end |