module Logstop

Constants

CREDIT_CARD_REGEX
CREDIT_CARD_REGEX_DELIMITERS
EMAIL_REGEX
FILTERED_STR
FILTERED_URL_STR
IP_REGEX
PHONE_REGEX
SSN_REGEX
URL_PASSWORD_REGEX
VERSION

Public Class Methods

guard(logger, **options) click to toggle source
# File lib/logstop.rb, line 35
def self.guard(logger, **options)
  logger.formatter = Logstop::Formatter.new(logger.formatter, **options)
end
scrub(msg, ip: false, scrubber: nil) click to toggle source
# File lib/logstop.rb, line 17
def self.scrub(msg, ip: false, scrubber: nil)
  msg = msg.to_s.dup

  # order filters are applied is important
  msg.gsub!(URL_PASSWORD_REGEX, FILTERED_URL_STR)
  msg.gsub!(EMAIL_REGEX, FILTERED_STR)
  msg.gsub!(CREDIT_CARD_REGEX, FILTERED_STR)
  msg.gsub!(CREDIT_CARD_REGEX_DELIMITERS, FILTERED_STR)
  msg.gsub!(PHONE_REGEX, FILTERED_STR)
  msg.gsub!(SSN_REGEX, FILTERED_STR)

  msg.gsub!(IP_REGEX, FILTERED_STR) if ip

  msg = scrubber.call(msg) if scrubber

  msg
end