Class: LibvirtAsync::LogFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/libvirt_async/log_formatter.rb

Constant Summary collapse

LOG_FORMAT =
"%s, %s [%d/%s/%s] %s\n".freeze
DEFAULT_DATETIME_FORMAT =
"%F %T.%N".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogFormatter

Returns a new instance of LogFormatter.



10
11
12
# File 'lib/libvirt_async/log_formatter.rb', line 10

def initialize
  @datetime_format = nil
end

Instance Attribute Details

#datetime_formatObject

Returns the value of attribute datetime_format.



8
9
10
# File 'lib/libvirt_async/log_formatter.rb', line 8

def datetime_format
  @datetime_format
end

Instance Method Details

#call(severity, time, progname, message) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/libvirt_async/log_formatter.rb', line 14

def call(severity, time, progname, message)
  LOG_FORMAT % [
      severity[0..0],
      format_datetime(time),
      Process.pid,
      "0x#{Fiber.current.object_id.to_s(16)}",
      progname,
      format_message(message)
  ]
end