Class: Fluent::FileOutputWithFixPath
- Inherits:
-
TimeSlicedOutput
- Object
- TimeSlicedOutput
- Fluent::FileOutputWithFixPath
- Defined in:
- lib/fluent/plugin/out_file_with_fix_path.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ FileOutputWithFixPath
constructor
A new instance of FileOutputWithFixPath.
- #secondary_init(primary) ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ FileOutputWithFixPath
Returns a new instance of FileOutputWithFixPath.
7 8 9 10 |
# File 'lib/fluent/plugin/out_file_with_fix_path.rb', line 7 def initialize require 'time' super end |
Instance Method Details
#configure(conf) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fluent/plugin/out_file_with_fix_path.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 conf['buffer_path'] ||= @path super @formatter = Plugin.new_formatter(@format) @formatter.configure(conf) end |
#format(tag, time, record) ⇒ Object
27 28 29 |
# File 'lib/fluent/plugin/out_file_with_fix_path.rb', line 27 def format(tag, time, record) @formatter.format(tag, time, record) end |
#secondary_init(primary) ⇒ Object
38 39 40 |
# File 'lib/fluent/plugin/out_file_with_fix_path.rb', line 38 def secondary_init(primary) # don't warn even if primary.class is not FileOutput end |
#write(chunk) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/fluent/plugin/out_file_with_fix_path.rb', line 31 def write(chunk) FileUtils.mkdir_p File.dirname(@path) File.open(@path, "a", DEFAULT_FILE_PERMISSION) do |f| chunk.write_to(f) end end |