Class: Loga::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/loga/configuration.rb

Constant Summary collapse

FRAMEWORK_EXCEPTIONS =
%w[
  ActionController::RoutingError
  ActiveRecord::RecordNotFound
  Sinatra::NotFound
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_options = {}, framework_options = {}) ⇒ Configuration

rubocop:disable Metrics/MethodLength



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/loga/configuration.rb', line 22

def initialize(user_options = {}, framework_options = {})
  options = default_options.merge(framework_options)
                           .merge(environment_options)
                           .merge(user_options)

  self.device            = options[:device]
  self.filter_exceptions = options[:filter_exceptions]
  self.filter_parameters = options[:filter_parameters]
  self.format            = options[:format]
  self.host              = options[:host]
  self.level             = options[:level]
  self.service_name      = options[:service_name]
  self.service_version   = options[:service_version] || ServiceVersionStrategies.call
  self.sync              = options[:sync]
  self.tags              = options[:tags]
  self.hide_pii          = options[:hide_pii]

  validate

  @logger = initialize_logger
end

Instance Attribute Details

#deviceObject

Returns the value of attribute device.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def device
  @device
end

#filter_exceptionsObject

Returns the value of attribute filter_exceptions.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def filter_exceptions
  @filter_exceptions
end

#filter_parametersObject

Returns the value of attribute filter_parameters.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def filter_parameters
  @filter_parameters
end

#formatObject

Returns the value of attribute format.



19
20
21
# File 'lib/loga/configuration.rb', line 19

def format
  @format
end

#hide_piiObject

Returns the value of attribute hide_pii.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def hide_pii
  @hide_pii
end

#hostObject

Returns the value of attribute host.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def host
  @host
end

#levelObject

Returns the value of attribute level.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def level
  @level
end

#loggerObject (readonly)

Returns the value of attribute logger.



19
20
21
# File 'lib/loga/configuration.rb', line 19

def logger
  @logger
end

#service_nameObject

Returns the value of attribute service_name.



19
20
21
# File 'lib/loga/configuration.rb', line 19

def service_name
  @service_name
end

#service_versionObject

Returns the value of attribute service_version.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def service_version
  @service_version
end

#syncObject

Returns the value of attribute sync.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def sync
  @sync
end

#tagsObject

Returns the value of attribute tags.



17
18
19
# File 'lib/loga/configuration.rb', line 17

def tags
  @tags
end

Instance Method Details

#structured?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/loga/configuration.rb', line 53

def structured?
  format == :gelf
end