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.4.0'
Class Method Summary
collapse
Class Method Details
.build_logger(io, formatter: LogFormatter.new, progname: nil, level: :info, datetime_format: nil) ⇒ Object
42
43
44
45
|
# File 'lib/libvirt_async.rb', line 42
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
36
37
38
|
# File 'lib/libvirt_async.rb', line 36
def logger
@logger
end
|
.logger=(value) ⇒ Object
30
31
32
|
# File 'lib/libvirt_async.rb', line 30
def logger=(value)
@logger = value
end
|
.register_implementations! ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/libvirt_async.rb', line 11
def register_implementations!
return false unless @implementations.nil?
@implementations = Implementations.new
@implementations.start
true
end
|
.start_debug_logging!(timeout = 2) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/libvirt_async.rb', line 55
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
74
75
76
77
|
# File 'lib/libvirt_async.rb', line 74
def stop_debug_logging!
@debug_task&.stop(true)
@debug_task = nil
end
|
.unregister_implementations! ⇒ Object
21
22
23
24
25
26
|
# File 'lib/libvirt_async.rb', line 21
def unregister_implementations!
return false if @implementations.nil?
@implementations.stop
@implementations = nil
true
end
|
.use_logger!(io = STDOUT, **options) ⇒ Object
49
50
51
|
# File 'lib/libvirt_async.rb', line 49
def use_logger!(io = STDOUT, **options)
self.logger = build_logger(io, **options)
end
|