Class: DohLog::Interface

Inherits:
Object show all
Defined in:
lib/dohlog/interface.rb

Constant Summary collapse

@@acceptor =
nil
@@enabled =
false

Class Method Summary collapse

Instance Method Summary collapse

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

.disableObject



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

.enableObject



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

.shutdownObject



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

#info(msg, exception = nil) ⇒ Object



43
44
45
46
47
# File 'lib/dohlog/interface.rb', line 43

def info(msg, exception = nil)
  if @@enabled && @@acceptor
    @@acceptor.add(Event.new(DohLog::INFO, msg, @location, exception))
  end
end

#warn(msg, exception = nil) ⇒ Object



49
50
51
52
53
# File 'lib/dohlog/interface.rb', line 49

def warn(msg, exception = nil)
  if @@enabled && @@acceptor
    @@acceptor.add(Event.new(DohLog::WARN, msg, @location, exception))
  end
end