Module: Libvirt::Loggable

Included in:
Connection
Defined in:
lib/libvirt/loggable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



31
32
33
34
# File 'lib/libvirt/loggable.rb', line 31

def self.included(base)
  base.extend ClassMethods
  super
end

Instance Method Details

#dbg(prog_name = nil, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/libvirt/loggable.rb', line 36

def dbg(prog_name = nil, &block)
  return if Libvirt.logger.nil?

  if prog_name.nil?
    meth = caller[0].match(/`(.*)'/)[1]
    meth = "<#{meth}>" if meth.include?(' ')
    prog_name = "#{self.class.name}##{meth}"
  end
  Libvirt.logger.debug(prog_name, &block)
end

#err(prog_name = nil, &block) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/libvirt/loggable.rb', line 47

def err(prog_name = nil, &block)
  return if Libvirt.logger.nil?

  if prog_name.nil?
    meth = caller[0].match(/`(.*)'/)[1]
    meth = "<#{meth}>" if meth.include?(' ')
    prog_name = "#{self.class.name}##{meth}"
  end
  Libvirt.logger.error(prog_name, &block)
end