class Fluent::ParsePostfixFilter

Public Instance Methods

filter(tag, time, record) click to toggle source
# 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