Skip to content

Commit

Permalink
Merge pull request logstash-plugins#5 from wiibaa/decorate
Browse files Browse the repository at this point in the history
Avoid overriding path if already present in json and decorate last
  • Loading branch information
talevy committed May 16, 2015
2 parents eb75ceb + d0a1781 commit 7724fb5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/logstash/inputs/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def register
require "filewatch/tail"
require "digest/md5"
@logger.info("Registering file input", :path => @path)
@host = Socket.gethostname.force_encoding(Encoding::UTF_8)

@tail_config = {
:exclude => @exclude,
Expand Down Expand Up @@ -131,14 +132,14 @@ def run(queue)
@tail = FileWatch::Tail.new(@tail_config)
@tail.logger = @logger
@path.each { |path| @tail.tail(path) }
hostname = Socket.gethostname

@tail.subscribe do |path, line|
@logger.debug? && @logger.debug("Received line", :path => path, :text => line)
@codec.decode(line) do |event|
event["[@metadata][path]"] = path
event["host"] = @host if !event.include?("host")
event["path"] = path if !event.include?("path")
decorate(event)
event["host"] = hostname if !event.include?("host")
event["path"] = path
queue << event
end
end
Expand Down

0 comments on commit 7724fb5

Please sign in to comment.