lib/fluent/plugin/in_systemd.rb in fluent-plugin-systemd-0.0.1 vs lib/fluent/plugin/in_systemd.rb in fluent-plugin-systemd-0.0.2
- old
+ new
@@ -7,10 +7,11 @@
config_param :path, :string, default: '/var/log/journal'
config_param :filters, :array, default: []
config_param :pos_file, :string, default: nil
config_param :read_from_head, :bool, default: false
+ config_param :strip_underscores, :bool, default: false
config_param :tag, :string
attr_reader :tag
def configure(conf)
@@ -35,19 +36,20 @@
pos_writer.shutdown
end
private
- attr_reader :journal, :running, :lock, :cursor, :path, :pos_writer
+ attr_reader :journal, :running, :lock, :cursor, :path, :pos_writer, :strip_underscores
def run
watch do |entry|
router.emit(tag, entry.realtime_timestamp.to_i, formatted(entry))
end
end
def formatted(entry)
- entry.to_h
+ return entry.to_h unless strip_underscores
+ Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/, ''), v] }]
end
def watch
while running
next unless journal.wait(1_000_000)