require 'credit_card_sanitizer'

module MidasClient
  module Util
    def log(text)
      Rails.logger.info "[MIDAS_CLIENT][CALLER:#{caller[0][/`([^']*)'/, 1]}][#{Time.now.strftime("%d/%m/%Y %H:%M:%S.%L")}]#{text}"
    end

    def error_log(text)
      Rails.error "[MIDAS_CLIENT][ERROR][CALLER:#{caller[0][/`([^']*)'/, 1]}][#{Time.now.strftime("%d/%m/%Y %H:%M:%S.%L")}]#{text}"
    end

    def sanitize_pci(text)
      CreditCardSanitizer.new(replacement_token: '@').sanitize!(text.to_s) || text
    end
  end
end