Sha256: ceb756c23936bef2080a2379fafed1f41fa2d4f1e1078e278088da4e591c33c8
Contents?: true
Size: 981 Bytes
Versions: 5
Compression:
Stored size: 981 Bytes
Contents
require "timber/event" module Timber module Events # The SQL query event tracks sql queries to your database. # # @note This event should be installed automatically through integrations, # such as the {Integrations::ActiveRecord::LogSubscriber} integration. class SQLQuery < Timber::Event attr_reader :sql, :time_ms, :message def initialize(attributes) @sql = attributes[:sql] || raise(ArgumentError.new(":sql is required")) @time_ms = attributes[:time_ms] || raise(ArgumentError.new(":time_ms is required")) @time_ms = @time_ms.round(6) @message = attributes[:message] || raise(ArgumentError.new(":message is required")) end def to_hash {sql: sql, time_ms: time_ms} end alias to_h to_hash # Builds a hash representation of containing simply objects, suitable for serialization. def as_json(_options = {}) {:sql_query => to_hash} end end end end
Version data entries
5 entries across 5 versions & 1 rubygems