Class: LogStruct::Log::SQL

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Includes:
Interfaces::AdditionalDataField, Interfaces::CommonFields, LogStruct::Log::Shared::MergeAdditionalDataFields, LogStruct::Log::Shared::SerializeCommon
Defined in:
lib/log_struct/log/sql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LogStruct::Log::Shared::SerializeCommon

#as_json, #serialize, #serialize_common

Methods included from Interfaces::CommonFields

#serialize

Methods included from LogStruct::Log::Shared::MergeAdditionalDataFields

#merge_additional_data_fields

Constructor Details

#initialize(source: Source::App, event: Event::Database, timestamp:, level: Level::Info, message:, sql:, name:, duration_ms:, row_count: nil, adapter: nil, bind_params: nil, database_name: nil, connection_pool_size: nil, active_connections: nil, operation_type: nil, table_names: nil, additional_data: nil) ⇒ void

Parameters:

  • source (Source::App) (defaults to: Source::App)

    Shared/common fields

  • event (Event) (defaults to: Event::Database)
  • timestamp (Time)
  • level (Level) (defaults to: Level::Info)
  • message (String)

    Event-specific fields

  • sql (String)
  • name (String)
  • duration_ms (Float)
  • row_count (Integer, nil) (defaults to: nil)
  • adapter (String, nil) (defaults to: nil)
  • bind_params (Array<T.untyped>, nil) (defaults to: nil)
  • database_name (String, nil) (defaults to: nil)
  • connection_pool_size (Integer, nil) (defaults to: nil)
  • active_connections (Integer, nil) (defaults to: nil)
  • operation_type (String, nil) (defaults to: nil)
  • table_names (Array<String>, nil) (defaults to: nil)
  • additional_data (Hash{String, Symbol => T.untyped}, nil) (defaults to: nil)


# File ''

const :source, Source::App, default: Source::App
const :event, Event, default: Event::Database
const :timestamp, Time, factory: -> { Time.now }
const :level, Level, default: Level::Info
const :message, String
const :sql, String
const :name, String
const :duration_ms, Float
const :row_count, T.nilable(Integer), default: nil
const :adapter, T.nilable(String), default: nil
const :bind_params, T.nilable(T::Array[T.untyped]), default: nil
const :database_name, T.nilable(String), default: nil
const :connection_pool_size, T.nilable(Integer), default: nil
const :active_connections, T.nilable(Integer), default: nil
const :operation_type, T.nilable(String), default: nil
const :table_names, T.nilable(T::Array[String]), default: nil
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil

Instance Attribute Details

#active_connectionsInteger? (readonly)

Returns the value of prop active_connections.

Returns:

  • (Integer, nil)


# File ''

const :active_connections, T.nilable(Integer), default: nil

#adapterString? (readonly)

Returns the value of prop adapter.

Returns:

  • (String, nil)


# File ''

const :adapter, T.nilable(String), default: nil

#additional_dataHash{String, Symbol => T.untyped}? (readonly)

Returns the value of prop additional_data.

Returns:

  • (Hash{String, Symbol => T.untyped}, nil)


# File ''

const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil

#bind_paramsArray<T.untyped>? (readonly)

Returns the value of prop bind_params.

Returns:

  • (Array<T.untyped>, nil)


# File ''

const :bind_params, T.nilable(T::Array[T.untyped]), default: nil

#connection_pool_sizeInteger? (readonly)

Returns the value of prop connection_pool_size.

Returns:

  • (Integer, nil)


# File ''

const :connection_pool_size, T.nilable(Integer), default: nil

#database_nameString? (readonly)

Returns the value of prop database_name.

Returns:

  • (String, nil)


# File ''

const :database_name, T.nilable(String), default: nil

#duration_msFloat (readonly)

Returns the value of prop duration_ms.

Returns:

  • (Float)


# File ''

const :duration_ms, Float

#eventEvent (readonly)

Returns the value of prop event.

Returns:



# File ''

const :event, Event, default: Event::Database

#levelLevel (readonly)

Returns the value of prop level.

Returns:



# File ''

const :level, Level, default: Level::Info

#messageString (readonly)

Event-specific fields

Returns:

  • (String)


# File ''

const :message, String

#nameString (readonly)

Returns the value of prop name.

Returns:

  • (String)


# File ''

const :name, String

#operation_typeString? (readonly)

Returns the value of prop operation_type.

Returns:

  • (String, nil)


# File ''

const :operation_type, T.nilable(String), default: nil

#row_countInteger? (readonly)

Returns the value of prop row_count.

Returns:

  • (Integer, nil)


# File ''

const :row_count, T.nilable(Integer), default: nil

#sourceSource::App (readonly)

Shared/common fields

Returns:



# File ''

const :source, Source::App, default: Source::App

#sqlString (readonly)

Returns the value of prop sql.

Returns:

  • (String)


# File ''

const :sql, String

#table_namesArray<String>? (readonly)

Returns the value of prop table_names.

Returns:

  • (Array<String>, nil)


# File ''

const :table_names, T.nilable(T::Array[String]), default: nil

#timestampTime (readonly)

Returns the value of prop timestamp.

Returns:

  • (Time)


# File ''

const :timestamp, Time, factory: -> { Time.now }

Instance Method Details

#to_hHash{LogStruct::LogField => T.untyped}

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/log_struct/log/sql.rb', line 55

def to_h
  h = T.let({}, T::Hash[LogStruct::LogField, T.untyped])
  h[LogField::Message] = message
  h[LogField::Sql] = sql
  h[LogField::Name] = name
  h[LogField::DurationMs] = duration_ms
  h[LogField::RowCount] = row_count unless row_count.nil?
  h[LogField::Adapter] = adapter unless adapter.nil?
  h[LogField::BindParams] = bind_params unless bind_params.nil?
  h[LogField::DatabaseName] = database_name unless database_name.nil?
  h[LogField::ConnectionPoolSize] = connection_pool_size unless connection_pool_size.nil?
  h[LogField::ActiveConnections] = active_connections unless active_connections.nil?
  h[LogField::OperationType] = operation_type unless operation_type.nil?
  h[LogField::TableNames] = table_names unless table_names.nil?
  h
end