class TeeLogger::Filter::CLI

The CLI filter takes sequences of strings of the form [“word”, “value”] and obfuscates the value if the word matches.

Constants

FILTER_TYPES
WINDOW_SIZE

Public Class Methods

new(*args) click to toggle source
Calls superclass method TeeLogger::Filter::FilterBase::new
# File lib/teelogger/filters/cli.rb, line 19
def initialize(*args)
  super(*args)

  # We create more complex matches out of the filter words passed.
  @matches = []
  run_data[:words].each do |word|
    @matches << /(-{0,2}#{word})(.*)/i
  end
end

Public Instance Methods

process(*args) click to toggle source
# File lib/teelogger/filters/cli.rb, line 29
def process(*args)
  # In case the window is too small, ignore it
  if args.size < 2
    return args
  end

  # Otherwise, if the first argument matches, we'll redact the second.
  @matches.each do |word|
    if word.match(args[0])
      args[1] = ::TeeLogger::Filter::REDACTED_WORD
    end
  end
  return args
end