Class: PaypalServerSdk::RequestLoggingConfiguration

Inherits:
CoreLibrary::ApiRequestLoggingConfiguration
  • Object
show all
Defined in:
lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb

Overview

Initializes a new instance of RequestLoggingConfiguration.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_body: false, log_headers: false, headers_to_include: nil, headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: false) ⇒ RequestLoggingConfiguration

Returns a new instance of RequestLoggingConfiguration.

Parameters:

  • log_body (Boolean) (defaults to: false)

    Indicates whether the message body should be logged. Default is false.

  • log_headers (Boolean) (defaults to: false)

    Indicates whether the message headers should be logged. Default is false.

  • headers_to_exclude (Array<String>) (defaults to: nil)

    Array of headers not displayed in logging. Default is an empty array.

  • headers_to_include (Array<String>) (defaults to: nil)

    Array of headers to be displayed in logging. Default is an empty array.

  • headers_to_unmask (Array<String>) (defaults to: nil)

    Array of headers which values are non-sensitive to display in logging. Default is an empty array.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 15

def initialize(log_body: false, log_headers: false, headers_to_include: nil,
               headers_to_exclude: nil, headers_to_unmask: nil,
               include_query_in_path: false)
  super(
    log_body,
    log_headers,
    headers_to_exclude,
    headers_to_include,
    headers_to_unmask,
    include_query_in_path
  )
end

Class Method Details

.any_logging_configured?Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
71
72
73
74
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 65

def self.any_logging_configured?
  %w[
    REQUEST_LOG_BODY
    REQUEST_LOG_HEADERS
    REQUEST_HEADERS_TO_INCLUDE
    REQUEST_HEADERS_TO_EXCLUDE
    REQUEST_HEADERS_TO_UNMASK
    REQUEST_INCLUDE_QUERY_IN_PATH
  ].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
end

.from_envObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 47

def self.from_env
  log_body = ENV['REQUEST_LOG_BODY']
  log_headers = ENV['REQUEST_LOG_HEADERS']
  headers_to_include = ENV['REQUEST_HEADERS_TO_INCLUDE']
  headers_to_exclude = ENV['REQUEST_HEADERS_TO_EXCLUDE']
  headers_to_unmask = ENV['REQUEST_HEADERS_TO_UNMASK']
  include_query_in_path = ENV['REQUEST_INCLUDE_QUERY_IN_PATH']

  new(
    log_body: log_body,
    log_headers: log_headers,
    headers_to_include: headers_to_include,
    headers_to_exclude: headers_to_exclude,
    headers_to_unmask: headers_to_unmask,
    include_query_in_path: include_query_in_path
  )
end

Instance Method Details

#clone_with(log_body: nil, log_headers: nil, headers_to_include: nil, headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 28

def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
               headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: nil)
  log_body ||= self.log_body
  log_headers ||= self.log_headers
  headers_to_include ||= self.headers_to_include
  headers_to_exclude ||= self.headers_to_exclude
  headers_to_unmask ||= self.headers_to_unmask
  include_query_in_path ||= self.include_query_in_path

  RequestLoggingConfiguration.new(
    log_body: log_body,
    log_headers: log_headers,
    headers_to_include: headers_to_include,
    headers_to_exclude: headers_to_exclude,
    headers_to_unmask: headers_to_unmask,
    include_query_in_path: include_query_in_path
  )
end