Class: Synchrotron::Logger
- Inherits:
-
Object
- Object
- Synchrotron::Logger
- Defined in:
- lib/synchrotron/logger.rb
Constant Summary collapse
- LEVELS =
{ :fatal => 0, :error => 1, :warn => 2, :info => 3, :debug => 4, :insane => 5 }
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #const_missing(name) ⇒ Object
-
#initialize(level = :info, output = $stdout) ⇒ Logger
constructor
A new instance of Logger.
- #log(level, msg) ⇒ Object
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(level = :info, output = $stdout) ⇒ Logger
Returns a new instance of Logger.
15 16 17 18 |
# File 'lib/synchrotron/logger.rb', line 15 def initialize(level = :info, output = $stdout) self.level = level.to_sym self.output = output end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
25 26 27 28 |
# File 'lib/synchrotron/logger.rb', line 25 def method_missing(name, *args) return log(name, *args) if LEVELS.key?(name) raise NoMethodError, "undefined method: #{name}" end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
4 5 6 |
# File 'lib/synchrotron/logger.rb', line 4 def level @level end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/synchrotron/logger.rb', line 4 def output @output end |