Method: Systemd::JournalEntry#initialize

Defined in:
lib/systemd/journal_entry.rb

#initialize(entry, context = {}) ⇒ JournalEntry

Create a new JournalEntry from the given entry hash. You probably don’t need to construct this yourself; instead instances are returned from Systemd::Journal methods such as Systemd::Journal#current_entry.

Parameters:

  • entry (Hash)

    a hash containing all the key-value pairs associated with a given journal entry.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/systemd/journal_entry.rb', line 13

def initialize(entry, context = {})
  inspect = []
  @entry = entry
  @ctx = context
  @fields = entry.map do |key, value|
    name = key.downcase.to_sym
    define_singleton_method(name) { value } unless respond_to?(name)

    inspect.push("#{name}: '#{value}'")
    name
  end
  @inspect = inspect.join(", ")
end