Module: Libvirt::Loggable::ClassMethods

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

Overview

Instance Method Summary collapse

Instance Method Details

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



8
9
10
11
12
13
14
15
16
17
# File 'lib/libvirt/loggable.rb', line 8

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 = "#{name}.#{meth}"
  end
  Libvirt.logger.debug(prog_name, &block)
end

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



19
20
21
22
23
24
25
26
27
28
# File 'lib/libvirt/loggable.rb', line 19

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 = "#{name}.#{meth}"
  end
  Libvirt.logger.error(prog_name, &block)
end