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.



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

def initialize
  @datetime_format = nil
end

Instance Attribute Details

#datetime_formatObject

Returns the value of attribute datetime_format.



6
7
8
# File 'lib/libvirt_async/log_formatter.rb', line 6

def datetime_format
  @datetime_format
end

Instance Method Details

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



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

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