Class: Fluent::StdoutPPOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::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
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ StdoutPPOutput
constructor
A new instance of StdoutPPOutput.
Constructor Details
#initialize ⇒ StdoutPPOutput
Returns a new instance of StdoutPPOutput.
23 24 25 |
# File 'lib/fluent/plugin/out_stdout_pp.rb', line 23 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin/out_stdout_pp.rb', line 27 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 |
#emit(tag, es, chain) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fluent/plugin/out_stdout_pp.rb', line 41 def emit(tag, es, chain) 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 chain.next end |