Class: DohLog::Interface
Constant Summary collapse
- @@acceptor =
nil
- @@enabled =
false
Class Method Summary collapse
Instance Method Summary collapse
- #debug(msg, exception = nil) ⇒ Object
- #error(msg, exception = nil) ⇒ Object
- #info(msg, exception = nil) ⇒ Object
-
#initialize(location) ⇒ Interface
constructor
A new instance of Interface.
- #warn(msg, exception = nil) ⇒ Object
Constructor Details
#initialize(location) ⇒ Interface
Returns a new instance of Interface.
33 34 35 |
# File 'lib/dohlog/interface.rb', line 33 def initialize(location) @location = location end |
Class Method Details
.disable ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dohlog/interface.rb', line 22 def self.disable @@enabled = false if block_given? begin yield ensure @@enabled = true end end end |
.enable ⇒ Object
18 19 20 |
# File 'lib/dohlog/interface.rb', line 18 def self.enable @@enabled = true end |
.setup(acceptor) ⇒ Object
9 10 11 12 |
# File 'lib/dohlog/interface.rb', line 9 def self.setup(acceptor) @@acceptor = acceptor @@enabled = true end |
.shutdown ⇒ Object
14 15 16 |
# File 'lib/dohlog/interface.rb', line 14 def self.shutdown @@acceptor.shutdown end |
Instance Method Details
#debug(msg, exception = nil) ⇒ Object
37 38 39 40 41 |
# File 'lib/dohlog/interface.rb', line 37 def debug(msg, exception = nil) if @@enabled && @@acceptor @@acceptor.add(Event.new(DohLog::DEBUG, msg, @location, exception)) end end |
#error(msg, exception = nil) ⇒ Object
55 56 57 58 59 |
# File 'lib/dohlog/interface.rb', line 55 def error(msg, exception = nil) if @@enabled && @@acceptor @@acceptor.add(Event.new(DohLog::ERROR, msg, @location, exception)) end end |