Class: LogStruct::Configuration

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Includes:
Sorbet::SerializeSymbolKeys
Defined in:
lib/log_struct/configuration.rb

Overview

Core configuration class that provides a type-safe API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sorbet::SerializeSymbolKeys

#serialize, #to_h

Constructor Details

#initialize(enabled: true, enabled_environments:, local_environments:, integrations:, filters:, string_scrubbing_handler: nil, error_reporting_handler: nil, error_handling_modes:) ⇒ void

Parameters:

  • enabled (Boolean) (defaults to: true)

    Props

  • enabled_environments (Array<Symbol>)
  • local_environments (Array<Symbol>)
  • integrations (ConfigStruct::Integrations)
  • filters (ConfigStruct::Filters)
  • string_scrubbing_handler (Handlers::StringScrubber, nil) (defaults to: nil)

    Custom log scrubbing handler for any additional string scrubbing Default: nil

  • error_reporting_handler (Handlers::ErrorReporter, nil) (defaults to: nil)

    Custom handler for error reporting Default: Errors are handled by MultiErrorReporter (auto-detects Sentry, Bugsnag, Rollbar, Honeybadger, etc.)

  • error_handling_modes (ConfigStruct::ErrorHandlingModes)

    How to handle errors from various sources



# File ''

prop :enabled, T::Boolean, default: true
prop :enabled_environments, T::Array[Symbol], factory: -> { [:test, :production] }
prop :local_environments, T::Array[Symbol], factory: -> { [:development, :test] }
const :integrations, ConfigStruct::Integrations, factory: -> { ConfigStruct::Integrations.new }
const :filters, ConfigStruct::Filters, factory: -> { ConfigStruct::Filters.new }
prop :string_scrubbing_handler, T.nilable(Handlers::StringScrubber)
prop :error_reporting_handler, T.nilable(Handlers::ErrorReporter), default: nil
const :error_handling_modes,
ConfigStruct::ErrorHandlingModes,
factory: -> {
  ConfigStruct::ErrorHandlingModes.new
}

Instance Attribute Details

#enabledBoolean


Props

Returns:

  • (Boolean)


# File ''

prop :enabled, T::Boolean, default: true

#enabled_environmentsArray<Symbol>

Returns the value of prop enabled_environments.

Returns:

  • (Array<Symbol>)


# File ''

prop :enabled_environments, T::Array[Symbol], factory: -> { [:test, :production] }

#error_handling_modesConfigStruct::ErrorHandlingModes (readonly)

How to handle errors from various sources



# File ''

const :error_handling_modes,
ConfigStruct::ErrorHandlingModes,
factory: -> {
  ConfigStruct::ErrorHandlingModes.new
}

#error_reporting_handlerHandlers::ErrorReporter?

Custom handler for error reporting Default: Errors are handled by MultiErrorReporter (auto-detects Sentry, Bugsnag, Rollbar, Honeybadger, etc.)

Returns:



# File ''

prop :error_reporting_handler, T.nilable(Handlers::ErrorReporter), default: nil

#filtersConfigStruct::Filters (readonly)

Returns the value of prop filters.



# File ''

const :filters, ConfigStruct::Filters, factory: -> { ConfigStruct::Filters.new }

#integrationsConfigStruct::Integrations (readonly)

Returns the value of prop integrations.



# File ''

const :integrations, ConfigStruct::Integrations, factory: -> { ConfigStruct::Integrations.new }

#local_environmentsArray<Symbol>

Returns the value of prop local_environments.

Returns:

  • (Array<Symbol>)


# File ''

prop :local_environments, T::Array[Symbol], factory: -> { [:development, :test] }

#string_scrubbing_handlerHandlers::StringScrubber?

Custom log scrubbing handler for any additional string scrubbing Default: nil

Returns:



# File ''

prop :string_scrubbing_handler, T.nilable(Handlers::StringScrubber)

Class Method Details

.instanceConfiguration

Returns:



50
51
52
# File 'lib/log_struct/configuration.rb', line 50

def self.instance
  @instance ||= T.let(Configuration.new, T.nilable(Configuration))
end

.set_instance(config) ⇒ void

This method returns an undefined value.

Parameters:



55
56
57
# File 'lib/log_struct/configuration.rb', line 55

def self.set_instance(config)
  @instance = config
end