Class: Fluent::Plugin::StdoutPPOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::StdoutPPOutput
- Defined in:
- lib/fluent/plugin/out_stdout_pp.rb
Constant Summary collapse
- TTY_COLOR =
{ normal: "\033[0;39m", red: "\033[1;31m", green: "\033[1;32m", yellow: "\033[1;33m", blue: "\033[1;34m", magenta: "\033[1;35m", cyan: "\033[1;36m", white: "\033[1;37m", }
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fluent/plugin/out_stdout_pp.rb', line 23 def configure(conf) super @time_color = @time_color.intern if TTY_COLOR[@time_color].nil? raise ConfigError, "stdout_pp: unknown color name #{@time_color} in time_color" end @tag_color = @tag_color.intern if TTY_COLOR[@tag_color].nil? raise ConfigError, "stdout_pp: unknown color name #{@tag_color} in tag_color" end end |
#multi_workers_ready? ⇒ Boolean
52 53 54 |
# File 'lib/fluent/plugin/out_stdout_pp.rb', line 52 def multi_workers_ready? true end |
#process(tag, es) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/plugin/out_stdout_pp.rb', line 37 def process(tag, es) tag_colored = TTY_COLOR[@tag_color] + tag + TTY_COLOR[:normal] es.each do |time, record| time_colored = TTY_COLOR[@time_color] + Time.at(time).localtime.to_s + TTY_COLOR[:normal] if @pp json = JSON.pretty_generate(record) else json = Yajl.dump(record) end json = CodeRay.scan(json, :json).terminal if @record_colored log.write "#{time_colored} #{tag_colored}: #{json}\n" end log.flush end |