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