Sha256: 4f204b8273c6bd6e11fe208bdbdd252d66520abddf1ac9bafd650829747f80a2

Contents?: true

Size: 1.13 KB

Versions: 40

Compression:

Stored size: 1.13 KB

Contents

# To reduce the noise of the SQL logs, this class changes INFO
# logs to DEBUG, and changes the ERROR logs that occur when
# Sequel doesn't know if a table/view exists or not to DEBUG,
# so that they don't freak newbies out when they start up the
# broker for the first time.

require 'delegate'

module PactBroker
  module DB
    class LogQuietener < SimpleDelegator
      def info *args
        __getobj__().debug(*args)
      end

      def error *args
        if error_is_about_table_not_existing?(args)
          __getobj__().debug(*reassure_people_that_this_is_expected(args))
        else
          __getobj__().error(*args)
        end
      end

      def error_is_about_table_not_existing?(args)
        args.first.is_a?(String) &&
          ( args.first.include?("PG::UndefinedTable") ||
            args.first.include?("no such table") ||
            args.first.include?("no such view"))
      end

      def reassure_people_that_this_is_expected(args)
        message = args.shift
        message = message + " Don't panic. This happens when Sequel doesn't know if a table/view exists or not."
        [message] + args
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
pact_broker-2.57.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.56.1 lib/pact_broker/db/log_quietener.rb
pact_broker-2.56.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.55.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.54.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.53.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.52.2 lib/pact_broker/db/log_quietener.rb
pact_broker-2.52.1 lib/pact_broker/db/log_quietener.rb
pact_broker-2.52.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.51.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.50.1 lib/pact_broker/db/log_quietener.rb
pact_broker-2.50.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.49.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.48.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.47.1 lib/pact_broker/db/log_quietener.rb
pact_broker-2.47.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.46.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.45.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.44.0 lib/pact_broker/db/log_quietener.rb
pact_broker-2.43.0 lib/pact_broker/db/log_quietener.rb