Class: Fluent::SameFileOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::SameFileOutput
- Defined in:
- lib/fluent/plugin/out_samefile.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain, key = "") ⇒ Object
- #format(tag, time, record) ⇒ Object
- #format_stream(tag, es) ⇒ Object
-
#initialize ⇒ SameFileOutput
constructor
A new instance of SameFileOutput.
- #write(data) ⇒ Object
Constructor Details
#initialize ⇒ SameFileOutput
8 9 10 |
# File 'lib/fluent/plugin/out_samefile.rb', line 8 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fluent/plugin/out_samefile.rb', line 12 def configure(conf) if path = conf['path'] @path = path end unless @path raise ConfigError, "'path' parameter is required on file output" end super FileUtils.mkdir_p File.dirname(@path) @formatter = Plugin.new_formatter(@format) @formatter.configure(conf) end |
#emit(tag, es, chain, key = "") ⇒ Object
38 39 40 41 |
# File 'lib/fluent/plugin/out_samefile.rb', line 38 def emit(tag, es, chain, key="") data = format_stream(tag, es) write(data) end |
#format(tag, time, record) ⇒ Object
28 29 30 |
# File 'lib/fluent/plugin/out_samefile.rb', line 28 def format(tag, time, record) @formatter.format(tag, time, record) end |
#format_stream(tag, es) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/fluent/plugin/out_samefile.rb', line 43 def format_stream(tag, es) out = '' es.each {|time,record| out << format(tag, time, record) } out end |
#write(data) ⇒ Object
32 33 34 35 36 |
# File 'lib/fluent/plugin/out_samefile.rb', line 32 def write(data) File.open(@path, "a", DEFAULT_FILE_PERMISSION) do |f| f.write(data) end end |