Class: Fluent::ParsePostfixFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_parse_postfix.rb

Instance Method Summary collapse

Instance Method Details

#filter(tag, time, record) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fluent/plugin/filter_parse_postfix.rb', line 17

def filter(tag, time, record)
  line = record[@key]
  return record unless line

  options = {mask: @mask, hash: @include_hash, salt: @salt, parse_time: @use_log_time, sha_algorithm: @sha_algorithm}

  if @parse_header_checks
    parsed = PostfixStatusLine.parse_header_checks(line, options)
  else
    parsed = PostfixStatusLine.parse(line, options)
  end

  unless parsed
    log.warn "cannot parse a postfix log: #{line}"
    return record
  end

  if @use_log_time and parsed['epoch']
    time = parsed.delete('epoch')
  end

  parsed
rescue => e
  log.warn "failed to parse a postfix log: #{line}", :error_class => e.class, :error => e.message
  log.warn_backtrace
  record
end