Sha256: 4ba78276b26a379293a319acbfd9550b202cab489c71ed12a607ef165e6990c4

Contents?: true

Size: 717 Bytes

Versions: 6

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

require 'sequel'

module Sequel
  class Database
    #
    # Fixed behaviour for Sequel's log_exception()
    #
    # Reason:
    #   * handled exceptions should not be logged as errors
    #   * unhandled exceptions will be logged at the application level
    #
    def log_exception(exception, message, *)
      text_message = "#{self.class}(#{exception.class}): #{exception.message}"
      logger_message = { m: text_message, sql: message }

      # In case logger does not support structured data, implement a #to_s method
      logger_message.define_singleton_method(:to_s) { text_message }
      log_each(:debug, logger_message)
    end
  end # class Database
end # module Sequel

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mimi-db-0.3.5 lib/mimi/db/extensions/sequel-database.rb
mimi-db-0.3.4 lib/mimi/db/extensions/sequel-database.rb
mimi-db-0.3.3 lib/mimi/db/extensions/sequel-database.rb
mimi-db-0.3.2 lib/mimi/db/extensions/sequel-database.rb
mimi-db-0.3.1 lib/mimi/db/extensions/sequel-database.rb
mimi-db-0.3.0 lib/mimi/db/extensions/sequel-database.rb