Skip to content

Commit

Permalink
Merge pull request #606 from kawanet/fluent-cat-format-none
Browse files Browse the repository at this point in the history
fluent-cat --format none added
  • Loading branch information
repeatedly committed Jun 1, 2015
2 parents 2019123 + 3c82a4b commit 1598cac
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

config_path = Fluent::DEFAULT_CONFIG_PATH
format = 'json'
message_key = 'message'

op.on('-p', '--port PORT', "fluent tcp port (default: #{port})", Integer) {|i|
port = i
Expand Down Expand Up @@ -57,6 +58,14 @@
format = 'msgpack'
}

op.on('--none', "same as: -f none", TrueClass) {|b|
format = 'none'
}

op.on('--message-key KEY', "key field for none format (default: #{message_key})") {|s|
message_key = s
}

(class<<self;self;end).module_eval do
define_method(:usage) do |msg|
puts op.to_s
Expand Down Expand Up @@ -290,6 +299,17 @@ def abort_message(time, record)
exit 1
end

when 'none'
begin
while line = $stdin.gets
record = { message_key => line.chomp }
w.write(record)
end
rescue
$stderr.puts $!
exit 1
end

else
$stderr.puts "Unknown format '#{format}'"
exit 1
Expand Down

0 comments on commit 1598cac

Please sign in to comment.