Class: Fluent::LinefeederFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::LinefeederFilter
- Defined in:
- lib/fluent/plugin/filter_linefeeder.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #filter(tag, time, record) ⇒ Object
-
#initialize ⇒ LinefeederFilter
constructor
A new instance of LinefeederFilter.
- #linefeed!(string) ⇒ Object
Constructor Details
#initialize ⇒ LinefeederFilter
Returns a new instance of LinefeederFilter.
9 10 11 12 |
# File 'lib/fluent/plugin/filter_linefeeder.rb', line 9 def initialize require 'string/scrub' if RUBY_VERSION.to_f < 2.1 super end |
Instance Method Details
#configure(conf) ⇒ Object
14 15 16 |
# File 'lib/fluent/plugin/filter_linefeeder.rb', line 14 def configure(conf) super end |
#filter(tag, time, record) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/fluent/plugin/filter_linefeeder.rb', line 18 def filter(tag, time, record) keys.each do |key| linefeed!(record[key]) if record[key] end record end |
#linefeed!(string) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/fluent/plugin/filter_linefeeder.rb', line 25 def linefeed!(string) begin string.gsub!("\\n", "\n") rescue ArgumentError => e raise e unless e..index("invalid byte sequence in") == 0 string.scrub!('?') retry end end |