Module: PayPal::SDK::Core::Logging

Included in:
API::DataTypes::Base, Config, Util::HTTPHelper
Defined in:
lib/paypal-sdk/core/logging.rb

Overview

Include Logging module to provide logger functionality.

Configure logger

Logging.logger = Logger.new(STDERR)

Example

include Logger
logger.info "Debug message"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loggerObject

Get or Create configured logger based on the default environment configuration



28
29
30
# File 'lib/paypal-sdk/core/logging.rb', line 28

def logger
  @logger ||= Logger.new(STDERR)
end

.logger=(logger) ⇒ Object

Set logger directly and clear the loggers cache.

Attributes

  • logger – Logger object

Example

Logging.logger = Logger.new(STDERR)


37
38
39
# File 'lib/paypal-sdk/core/logging.rb', line 37

def logger=(logger)
  @logger = logger
end

Instance Method Details

#log_event(message, &block) ⇒ Object



18
19
20
21
22
23
# File 'lib/paypal-sdk/core/logging.rb', line 18

def log_event(message, &block)
  start_time = Time.now
  block.call
ensure
  logger.info sprintf("[%.3fs] %s", Time.now - start_time, message)
end

#loggerObject

Get logger object



14
15
16
# File 'lib/paypal-sdk/core/logging.rb', line 14

def logger
  @logger ||= Logging.logger
end