Module: LogStruct

Extended by:
Concerns::Configuration::ClassMethods, Concerns::ErrorHandling::ClassMethods, Concerns::Logging::ClassMethods
Defined in:
lib/log_struct/version.rb,
lib/log_struct.rb,
lib/log_struct/log.rb,
lib/log_struct/log/sql.rb,
lib/log_struct/railtie.rb,
lib/log_struct/handlers.rb,
lib/log_struct/log_keys.rb,
lib/log_struct/formatter.rb,
lib/log_struct/log/error.rb,
lib/log_struct/log/plain.rb,
lib/log_struct/hash_utils.rb,
lib/log_struct/log/shrine.rb,
lib/log_struct/enums/event.rb,
lib/log_struct/enums/level.rb,
lib/log_struct/log/request.rb,
lib/log_struct/log/sidekiq.rb,
lib/log_struct/enums/source.rb,
lib/log_struct/integrations.rb,
lib/log_struct/log/good_job.rb,
lib/log_struct/log/security.rb,
lib/log_struct/configuration.rb,
lib/log_struct/param_filters.rb,
lib/log_struct/log/active_job.rb,
lib/log_struct/log/carrierwave.rb,
lib/log_struct/string_scrubber.rb,
lib/log_struct/concerns/logging.rb,
lib/log_struct/integrations/rack.rb,
lib/log_struct/log/action_mailer.rb,
lib/log_struct/log/active_storage.rb,
lib/log_struct/integrations/shrine.rb,
lib/log_struct/integrations/sorbet.rb,
lib/log_struct/enums/error_reporter.rb,
lib/log_struct/integrations/lograge.rb,
lib/log_struct/integrations/sidekiq.rb,
lib/log_struct/multi_error_reporter.rb,
lib/log_struct/config_struct/filters.rb,
lib/log_struct/integrations/good_job.rb,
lib/log_struct/semantic_logger/setup.rb,
lib/log_struct/concerns/configuration.rb,
lib/log_struct/semantic_logger/logger.rb,
lib/log_struct/concerns/error_handling.rb,
lib/log_struct/integrations/active_job.rb,
lib/log_struct/integrations/carrierwave.rb,
lib/log_struct/enums/error_handling_mode.rb,
lib/log_struct/semantic_logger/formatter.rb,
lib/log_struct/config_struct/integrations.rb,
lib/log_struct/integrations/action_mailer.rb,
lib/log_struct/integrations/active_record.rb,
lib/log_struct/integrations/active_storage.rb,
lib/log_struct/integrations/sidekiq/logger.rb,
lib/log_struct/log/shared/serialize_common.rb,
lib/log_struct/integrations/good_job/logger.rb,
lib/log_struct/log/interfaces/common_fields.rb,
lib/log_struct/log/interfaces/message_field.rb,
lib/log_struct/sorbet/serialize_symbol_keys.rb,
lib/log_struct/log/interfaces/request_fields.rb,
lib/log_struct/log/shared/add_request_fields.rb,
lib/log_struct/integrations/host_authorization.rb,
lib/log_struct/integrations/rack_error_handler.rb,
lib/log_struct/semantic_logger/color_formatter.rb,
lib/log_struct/config_struct/error_handling_modes.rb,
lib/log_struct/integrations/integration_interface.rb,
lib/log_struct/integrations/action_mailer/callbacks.rb,
lib/log_struct/integrations/good_job/log_subscriber.rb,
lib/log_struct/log/interfaces/additional_data_field.rb,
lib/log_struct/integrations/active_job/log_subscriber.rb,
lib/log_struct/log/shared/merge_additional_data_fields.rb,
lib/log_struct/integrations/action_mailer/event_logging.rb,
lib/log_struct/integrations/action_mailer/error_handling.rb,
lib/log_struct/integrations/rack_error_handler/middleware.rb,
lib/log_struct/integrations/action_mailer/metadata_collection.rb

Overview

typed: strict frozen_string_literal: true

Defined Under Namespace

Modules: Concerns, ConfigStruct, Handlers, HashUtils, Integrations, Log, SemanticLogger, Sorbet, StringScrubber Classes: Configuration, Error, ErrorHandlingMode, ErrorReporter, Event, Formatter, Level, MultiErrorReporter, ParamFilters, Railtie, Source

Constant Summary collapse

LogClassType =

Type aliases for all possible log types This should be updated whenever a new log type is added (Can't use sealed! unless we want to put everything in one giant file.)

T.type_alias do
  T.any(
    T.class_of(LogStruct::Log::CarrierWave),
    T.class_of(LogStruct::Log::ActionMailer),
    T.class_of(LogStruct::Log::ActiveStorage),
    T.class_of(LogStruct::Log::ActiveJob),
    T.class_of(LogStruct::Log::Error),
    T.class_of(LogStruct::Log::GoodJob),
    T.class_of(LogStruct::Log::Plain),
    T.class_of(LogStruct::Log::Request),
    T.class_of(LogStruct::Log::Security),
    T.class_of(LogStruct::Log::Shrine),
    T.class_of(LogStruct::Log::Sidekiq),
    T.class_of(LogStruct::Log::SQL)
  )
end
VERSION =
"0.0.2"
LOG_KEYS =

Define a mapping of property names to JSON keys

T.let({
# Ruby struct property name => JSON key name

# Shared fields
source: :src,
event: :evt,
timestamp: :ts,
level: :lvl,

# Common fields
message: :msg,
data: :data,

# Request-related fields
path: :path,
http_method: :method, # Use `http_method` because `method` is a reserved word
source_ip: :source_ip,
user_agent: :user_agent,
referer: :referer,
request_id: :request_id,

# HTTP-specific fields
format: :format,
controller: :controller,
action: :action,
status: :status,
duration: :duration,
view: :view,
db: :db,
params: :params,

# Security-specific fields
blocked_host: :blocked_host,
blocked_hosts: :blocked_hosts,
client_ip: :client_ip,
x_forwarded_for: :x_forwarded_for,

# Email-specific fields
to: :to,
from: :from,
subject: :subject,

# Error fields
err_class: :err_class,
backtrace: :backtrace,

# Job-specific fields
job_id: :job_id,
job_class: :job_class,
queue_name: :queue_name,
arguments: :arguments,
retry_count: :retry_count,

# Sidekiq-specific fields
process_id: :pid,
thread_id: :tid,
context: :ctx,

# Storage-specific fields (ActiveStorage)
checksum: :checksum,
exist: :exist,
url: :url,
prefix: :prefix,
range: :range,

# Storage-specific fields (Shrine)
storage: :storage,
operation: :op,
file_id: :file_id,
filename: :filename,
mime_type: :mime_type,
size: :size,
metadata: :metadata,
location: :location,
upload_options: :upload_opts,
download_options: :download_opts,
options: :opts,
uploader: :uploader,

# CarrierWave-specific fields
model: :model,
mount_point: :mount_point,

# SQL-specific fields
sql: :sql,
name: :name,
row_count: :row_count,
connection_adapter: :connection_adapter,
bind_params: :bind_params,
database_name: :database_name,
connection_pool_size: :connection_pool_size,
active_connections: :active_connections,
operation_type: :operation_type,
table_names: :table_names
  }.freeze,
T::Hash[Symbol, Symbol])

Method Summary

Methods included from Concerns::ErrorHandling::ClassMethods

error_handling_mode_for, handle_exception, log_and_report_error, log_error

Methods included from Concerns::Configuration::ClassMethods

config, configuration, configuration=, configure, enabled?, is_local?, is_production?, merge_rails_filter_parameters!, set_enabled_from_rails_env!

Methods included from Concerns::Logging::ClassMethods

debug, error, fatal, info, warn