Class: LogStruct::Log::Request
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::Request
- Extended by:
- T::Sig
- Includes:
- Interfaces::CommonFields, Interfaces::RequestFields, Shared::AddRequestFields, Shared::SerializeCommon
- Defined in:
- lib/log_struct/log/request.rb
Instance Attribute Summary collapse
-
#action ⇒ String?
readonly
Returns the value of prop
action. -
#controller ⇒ String?
readonly
Returns the value of prop
controller. -
#database ⇒ Float?
readonly
Returns the value of prop
database. -
#duration_ms ⇒ Float?
readonly
Returns the value of prop
duration_ms. -
#event ⇒ Event
readonly
Returns the value of prop
event. -
#format ⇒ Symbol?
readonly
Event-specific fields.
-
#http_method ⇒ String?
readonly
Returns the value of prop
http_method. -
#level ⇒ Level
readonly
Returns the value of prop
level. -
#params ⇒ Hash{Symbol => T.untyped}?
readonly
Returns the value of prop
params. -
#path ⇒ String?
readonly
Returns the value of prop
path. -
#referer ⇒ String?
readonly
Returns the value of prop
referer. -
#request_id ⇒ String?
readonly
Returns the value of prop
request_id. -
#source ⇒ Source::Rails
readonly
Shared/common fields.
-
#source_ip ⇒ String?
readonly
Returns the value of prop
source_ip. -
#status ⇒ Integer?
readonly
Returns the value of prop
status. -
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp. -
#user_agent ⇒ String?
readonly
Returns the value of prop
user_agent. -
#view ⇒ Float?
readonly
Returns the value of prop
view.
Instance Method Summary collapse
- #initialize(source: Source::Rails, event: Event::Request, timestamp:, level: Level::Info, path: nil, http_method: nil, source_ip: nil, user_agent: nil, referer: nil, request_id: nil, format: nil, controller: nil, action: nil, status: nil, duration_ms: nil, view: nil, database: nil, params: nil) ⇒ void constructor
- #to_h ⇒ Hash{LogStruct::LogField => T.untyped}
Methods included from Shared::AddRequestFields
Methods included from Shared::SerializeCommon
#as_json, #serialize, #serialize_common
Methods included from Interfaces::CommonFields
Constructor Details
#initialize(source: Source::Rails, event: Event::Request, timestamp:, level: Level::Info, path: nil, http_method: nil, source_ip: nil, user_agent: nil, referer: nil, request_id: nil, format: nil, controller: nil, action: nil, status: nil, duration_ms: nil, view: nil, database: nil, params: nil) ⇒ void
|
|
# File '' const :source, Source::Rails, default: Source::Rails const :event, Event, default: Event::Request const :timestamp, Time, factory: -> { Time.now } const :level, Level, default: Level::Info const :path, T.nilable(String), default: nil const :http_method, T.nilable(String), default: nil const :source_ip, T.nilable(String), default: nil const :user_agent, T.nilable(String), default: nil const :referer, T.nilable(String), default: nil const :request_id, T.nilable(String), default: nil const :format, T.nilable(Symbol), default: nil const :controller, T.nilable(String), default: nil const :action, T.nilable(String), default: nil const :status, T.nilable(Integer), default: nil const :duration_ms, T.nilable(Float), default: nil const :view, T.nilable(Float), default: nil const :database, T.nilable(Float), default: nil const :params, T.nilable(T::Hash[Symbol, T.untyped]), default: nil |
Instance Attribute Details
#action ⇒ String? (readonly)
Returns the value of prop action.
|
|
# File '' const :action, T.nilable(String), default: nil |
#controller ⇒ String? (readonly)
Returns the value of prop controller.
|
|
# File '' const :controller, T.nilable(String), default: nil |
#database ⇒ Float? (readonly)
Returns the value of prop database.
|
|
# File '' const :database, T.nilable(Float), default: nil |
#duration_ms ⇒ Float? (readonly)
Returns the value of prop duration_ms.
|
|
# File '' const :duration_ms, T.nilable(Float), default: nil |
#event ⇒ Event (readonly)
Returns the value of prop event.
|
|
# File '' const :event, Event, default: Event::Request |
#format ⇒ Symbol? (readonly)
Event-specific fields
|
|
# File '' const :format, T.nilable(Symbol), default: nil |
#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 |
#params ⇒ Hash{Symbol => T.untyped}? (readonly)
Returns the value of prop params.
|
|
# File '' const :params, T.nilable(T::Hash[Symbol, T.untyped]), default: nil |
#path ⇒ String? (readonly)
Returns the value of prop path.
|
|
# File '' const :path, T.nilable(String), default: nil |
#referer ⇒ String? (readonly)
Returns the value of prop referer.
|
|
# File '' const :referer, T.nilable(String), default: nil |
#request_id ⇒ String? (readonly)
Returns the value of prop request_id.
|
|
# File '' const :request_id, T.nilable(String), default: nil |
#source ⇒ Source::Rails (readonly)
Shared/common fields
|
|
# File '' const :source, Source::Rails, default: Source::Rails |
#source_ip ⇒ String? (readonly)
Returns the value of prop source_ip.
|
|
# File '' const :source_ip, T.nilable(String), default: nil |
#status ⇒ Integer? (readonly)
Returns the value of prop status.
|
|
# File '' const :status, T.nilable(Integer), default: nil |
#timestamp ⇒ Time (readonly)
Returns the value of prop timestamp.
|
|
# File '' const :timestamp, Time, factory: -> { Time.now } |
#user_agent ⇒ String? (readonly)
Returns the value of prop user_agent.
|
|
# File '' const :user_agent, T.nilable(String), default: nil |
#view ⇒ Float? (readonly)
Returns the value of prop view.
|
|
# File '' const :view, T.nilable(Float), default: nil |
Instance Method Details
#to_h ⇒ Hash{LogStruct::LogField => T.untyped}
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/log_struct/log/request.rb', line 57 def to_h h = T.let({}, T::Hash[LogStruct::LogField, T.untyped]) h[LogField::Path] = path unless path.nil? h[LogField::HttpMethod] = http_method unless http_method.nil? h[LogField::SourceIp] = source_ip unless source_ip.nil? h[LogField::UserAgent] = user_agent unless user_agent.nil? h[LogField::Referer] = referer unless referer.nil? h[LogField::RequestId] = request_id unless request_id.nil? h[LogField::Format] = format unless format.nil? h[LogField::Controller] = controller unless controller.nil? h[LogField::Action] = action unless action.nil? h[LogField::Status] = status unless status.nil? h[LogField::DurationMs] = duration_ms unless duration_ms.nil? h[LogField::View] = view unless view.nil? h[LogField::Database] = database unless database.nil? h[LogField::Params] = params unless params.nil? h end |