Class: ApiLogger::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



5
6
7
8
9
10
11
12
13
# File 'lib/api_logger/configuration.rb', line 5

def initialize
  @table_name = 'api_logs'
  @enabled = true
  @use_middleware = true
  @allowed_hosts = ['services.mfcentral.com', 'uatservices.mfcentral.com']
  # backwards compatibility, to be removed in next release.
  @exclude_hosts = []
  @exclude_routes = []
end

Instance Attribute Details

#allowed_hostsObject

Returns the value of attribute allowed_hosts.



3
4
5
# File 'lib/api_logger/configuration.rb', line 3

def allowed_hosts
  @allowed_hosts
end

#enabledObject

Returns the value of attribute enabled.



3
4
5
# File 'lib/api_logger/configuration.rb', line 3

def enabled
  @enabled
end

#exclude_hostsObject

Returns the value of attribute exclude_hosts.



3
4
5
# File 'lib/api_logger/configuration.rb', line 3

def exclude_hosts
  @exclude_hosts
end

#exclude_routesObject

Returns the value of attribute exclude_routes.



3
4
5
# File 'lib/api_logger/configuration.rb', line 3

def exclude_routes
  @exclude_routes
end

#table_nameObject

Returns the value of attribute table_name.



3
4
5
# File 'lib/api_logger/configuration.rb', line 3

def table_name
  @table_name
end

#use_middlewareObject

Returns the value of attribute use_middleware.



3
4
5
# File 'lib/api_logger/configuration.rb', line 3

def use_middleware
  @use_middleware
end

Instance Method Details

#should_log_route?(path, host = nil) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/api_logger/configuration.rb', line 15

def should_log_route?(path, host = nil)
  return false unless enabled && use_middleware
  return false unless host

  # Only log if host is in allowed list
  allowed_hosts.include?(host)
end