lib/sequel/database/logging.rb in sequel-5.23.0 vs lib/sequel/database/logging.rb in sequel-5.24.0
- old
+ new
@@ -33,11 +33,11 @@
end
# Yield to the block, logging any errors at error level to all loggers,
# and all other queries with the duration at warn or info level.
def log_connection_yield(sql, conn, args=nil)
- return yield if @loggers.empty?
+ return yield if skip_logging?
sql = "#{connection_info(conn) if conn && log_connection_info}#{sql}#{"; #{args.inspect}" if args}"
timer = Sequel.start_timer
begin
yield
@@ -55,9 +55,15 @@
def logger=(logger)
@loggers = Array(logger)
end
private
+
+ # Determine if logging should be skipped. Defaults to true if no loggers
+ # have been specified.
+ def skip_logging?
+ @loggers.empty?
+ end
# String including information about the connection, for use when logging
# connection info.
def connection_info(conn)
"(conn: #{conn.__id__}) "