Class: LogStruct::Log::Puma::Error
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::Puma::Error
- Extended by:
- T::Sig
- Includes:
- Interfaces::AdditionalDataField, Interfaces::CommonFields, Shared::MergeAdditionalDataFields, Shared::SerializeCommon
- Defined in:
- lib/log_struct/log/puma/error.rb
Constant Summary collapse
- FIELD_KEYS =
T.let( [LogField::ErrorClass, LogField::Message, LogField::Backtrace, LogField::ErrorContext, LogField::HttpMethod, LogField::Path].to_set(&:serialize).freeze, T::Set[Symbol] )
Constants included from Shared::MergeAdditionalDataFields
Shared::MergeAdditionalDataFields::NO_FIELD_KEYS, Shared::MergeAdditionalDataFields::RESERVED_KEYS
Instance Attribute Summary collapse
-
#additional_data ⇒ Hash{String, Symbol => T.untyped}?
readonly
Additional data.
-
#backtrace ⇒ Array<String>?
readonly
Returns the value of prop
backtrace. -
#error_class ⇒ T.class_of(Exception)
readonly
Event-specific fields.
-
#error_context ⇒ String?
readonly
Returns the value of prop
error_context. -
#event ⇒ Event
readonly
Returns the value of prop
event. -
#http_method ⇒ String?
readonly
Returns the value of prop
http_method. -
#level ⇒ Level
readonly
Returns the value of prop
level. -
#message ⇒ String
readonly
Returns the value of prop
message. -
#path ⇒ String?
readonly
Returns the value of prop
path. -
#source ⇒ Source::Puma
readonly
Shared/common fields.
-
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp.
Instance Method Summary collapse
- #field_keys ⇒ Set<Symbol>
- #initialize(source: Source::Puma, event: Event::Error, timestamp:, level: Level::Info, error_class:, message:, backtrace: nil, error_context: nil, http_method: nil, path: nil, additional_data: nil) ⇒ void constructor
- #to_h ⇒ Hash{LogStruct::LogField => T.untyped}
Methods included from Shared::SerializeCommon
#as_json, #serialize, #serialize_common
Methods included from Shared::MergeAdditionalDataFields
Methods included from Interfaces::CommonFieldBase
Constructor Details
#initialize(source: Source::Puma, event: Event::Error, timestamp:, level: Level::Info, error_class:, message:, backtrace: nil, error_context: nil, http_method: nil, path: nil, additional_data: nil) ⇒ void
|
|
# File '' const :source, Source::Puma, default: Source::Puma, override: true const :event, Event, default: Event::Error, override: true const :timestamp, Time, factory: -> { Time.now }, override: true const :level, Level, default: Level::Info, override: true const :error_class, T.class_of(Exception) const :message, String const :backtrace, T.nilable(T::Array[String]), default: nil const :error_context, T.nilable(String), default: nil const :http_method, T.nilable(String), default: nil const :path, T.nilable(String), default: nil const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil, override: true |
Instance Attribute Details
#additional_data ⇒ Hash{String, Symbol => T.untyped}? (readonly)
Additional data
|
|
# File '' const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil, override: true |
#backtrace ⇒ Array<String>? (readonly)
Returns the value of prop backtrace.
|
|
# File '' const :backtrace, T.nilable(T::Array[String]), default: nil |
#error_class ⇒ T.class_of(Exception) (readonly)
Event-specific fields
|
|
# File '' const :error_class, T.class_of(Exception) |
#error_context ⇒ String? (readonly)
Returns the value of prop error_context.
|
|
# File '' const :error_context, T.nilable(String), default: nil |
#event ⇒ Event (readonly)
Returns the value of prop event.
|
|
# File '' const :event, Event, default: Event::Error, override: true |
#http_method ⇒ String? (readonly)
Returns the value of prop http_method.
|
|
# File '' const :http_method, T.nilable(String), default: nil |
#level ⇒ Level (readonly)
Returns the value of prop level.
|
|
# File '' const :level, Level, default: Level::Info, override: true |
#message ⇒ String (readonly)
Returns the value of prop message.
|
|
# File '' const :message, String |
#path ⇒ String? (readonly)
Returns the value of prop path.
|
|
# File '' const :path, T.nilable(String), default: nil |
#source ⇒ Source::Puma (readonly)
Shared/common fields
|
|
# File '' const :source, Source::Puma, default: Source::Puma, override: true |
#timestamp ⇒ Time (readonly)
Returns the value of prop timestamp.
|
|
# File '' const :timestamp, Time, factory: -> { Time.now }, override: true |
Instance Method Details
#field_keys ⇒ Set<Symbol>
54 55 56 |
# File 'lib/log_struct/log/puma/error.rb', line 54 def field_keys FIELD_KEYS end |
#to_h ⇒ Hash{LogStruct::LogField => T.untyped}
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/log_struct/log/puma/error.rb', line 62 def to_h h = T.let({}, T::Hash[LogStruct::LogField, T.untyped]) h[LogField::ErrorClass] = error_class h[LogField::Message] = h[LogField::Backtrace] = backtrace unless backtrace.nil? h[LogField::ErrorContext] = error_context unless error_context.nil? h[LogField::HttpMethod] = http_method unless http_method.nil? h[LogField::Path] = path unless path.nil? h end |