Module: LibvirtAsync
- Defined in:
- lib/libvirt_async.rb,
lib/libvirt_async/util.rb,
lib/libvirt_async/error.rb,
lib/libvirt_async/timer.rb,
lib/libvirt_async/handle.rb,
lib/libvirt_async/version.rb,
lib/libvirt_async/with_dbg.rb,
lib/libvirt_async/stream_read.rb,
lib/libvirt_async/log_formatter.rb,
lib/libvirt_async/implementations.rb
Defined Under Namespace
Modules: Util, WithDbg
Classes: Error, Handle, Implementations, LogFormatter, StreamRead, Timer
Constant Summary
collapse
- VERSION =
'0.2.1'
Class Method Summary
collapse
Class Method Details
.build_logger(io, formatter: LogFormatter.new, progname: nil, level: :info, datetime_format: nil) ⇒ Object
40
41
42
43
|
# File 'lib/libvirt_async.rb', line 40
def build_logger(io, formatter: LogFormatter.new, progname: nil, level: :info, datetime_format: nil)
formatter&.datetime_format = datetime_format unless datetime_format.nil?
::Logger.new(io, formatter: formatter, progname: progname, level: level)
end
|
.logger ⇒ Object
34
35
36
|
# File 'lib/libvirt_async.rb', line 34
def logger
@logger
end
|
.logger=(value) ⇒ Object
28
29
30
|
# File 'lib/libvirt_async.rb', line 28
def logger=(value)
@logger = value
end
|
.register_implementations! ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/libvirt_async.rb', line 9
def register_implementations!
return false unless @implementations.nil?
@implementations = Implementations.new
@implementations.start
true
end
|
.start_debug_logging!(timeout = 2) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/libvirt_async.rb', line 53
def start_debug_logging!(timeout = 2)
LibvirtAsync.logger.debug { "scheduling debug logging!" }
@debug_task = Util.create_task do
LibvirtAsync.logger.debug { "starting debug logging!" }
begin
while true do
raise Error, 'implementations not registered' if @implementations.nil?
@implementations.print_debug_info
Async::Task.current.reactor.sleep timeout
end
rescue Error => e
LibvirtAsync.logger.debug { "stopping debug logging! #{e.message}" }
end
end
Async::Task.current.reactor << @debug_task.fiber
end
|
.stop_debug_logging! ⇒ Object
72
73
74
75
|
# File 'lib/libvirt_async.rb', line 72
def stop_debug_logging!
@debug_task&.stop(true)
@debug_task = nil
end
|
.unregister_implementations! ⇒ Object
19
20
21
22
23
24
|
# File 'lib/libvirt_async.rb', line 19
def unregister_implementations!
return false if @implementations.nil?
@implementations.stop
@implementations = nil
true
end
|
.use_logger!(io = STDOUT, options = {}) ⇒ Object
47
48
49
|
# File 'lib/libvirt_async.rb', line 47
def use_logger!(io = STDOUT, options = {})
self.logger = build_logger(io, options)
end
|