class Systemd::JournalEntry

Public Instance Methods

to_h_lower(is_lowercase) click to toggle source
# File lib/logstash/inputs/journald.rb, line 167
def to_h_lower(is_lowercase)
    if is_lowercase
        @entry.each_with_object({}) { |(k, v), h| h[k.downcase] = decode_value(v.dup) }
    else
        @entry.each_with_object({}) { |(k, v), h| h[k] = decode_value(v.dup) }
    end
end

Private Instance Methods

decode_value(value) click to toggle source

Field values are returned as binary (ASCII-8BIT) by the journal API. The officially recommended encoding is UTF-8, so trying that. If the result is not valid, using base64 representation instead. (see www.freedesktop.org/software/systemd/man/sd_journal_print.html#Description)

# File lib/logstash/inputs/journald.rb, line 180
def decode_value(value)
    value_utf8 = value.force_encoding('utf-8')
    if value_utf8.valid_encoding?
        value_utf8
    else
        Base64.encode64(value)
    end
end