From 3c82a4b6258c6b0e49e7ec5fa1c3ef0877f8d210 Mon Sep 17 00:00:00 2001 From: kawanet <u-suke@kawa.net> Date: Sat, 30 May 2015 07:00:30 +0900 Subject: [PATCH] fluent-cat --format none added --- lib/fluent/command/cat.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/fluent/command/cat.rb b/lib/fluent/command/cat.rb index 523df6483b..db7c0ed80f 100644 --- a/lib/fluent/command/cat.rb +++ b/lib/fluent/command/cat.rb @@ -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 @@ -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 @@ -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