Class: Fluent::NewTailPathInput

Inherits:
NewTailInput
  • Object
show all
Defined in:
lib/fluent/plugin/in_tail_path.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



8
9
10
# File 'lib/fluent/plugin/in_tail_path.rb', line 8

def configure(conf)
  super
end

#convert_line_to_event(line, es, tail_watcher) ⇒ Object

Override to add path field



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/in_tail_path.rb', line 15

def convert_line_to_event(line, es, tail_watcher)
  begin
    line.chomp!  # remove \n
    time, record = parse_line(line)
    if time && record
      record[@path_key] ||= tail_watcher.path unless @path_key.nil? # custom
      es.add(time, record)
    else
      log.warn "pattern not match: #{line.inspect}"
    end
  rescue => e
    log.warn line.dump, :error => e.to_s
    log.debug_backtrace(e)
  end
end

#parse_multilines(lines, tail_watcher) ⇒ Object

Override to pass tail_watcher to convert_line_to_event



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fluent/plugin/in_tail_path.rb', line 63

def parse_multilines(lines, tail_watcher)
  lb = tail_watcher.line_buffer
  es = ::Fluent::MultiEventStream.new
  lines.each { |line|
    if @parser.parser.firstline?(line)
      if lb
        convert_line_to_event(lb, es, tail_watcher)
      end
      lb = line
    else
      if lb.nil?
        log.warn "got incomplete line before first line from #{tail_watcher.path}: #{lb.inspect}"
      else
        lb << line
      end
    end
  }
  tail_watcher.line_buffer = lb
  es
end

#parse_singleline(lines, tail_watcher) ⇒ Object

Override to pass tail_watcher to convert_line_to_event



54
55
56
57
58
59
60
# File 'lib/fluent/plugin/in_tail_path.rb', line 54

def parse_singleline(lines, tail_watcher)
  es = ::Fluent::MultiEventStream.new
  lines.each { |line|
    convert_line_to_event(line, es, tail_watcher)
  }
  es
end