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
-
.logger ⇒ Object
Get or Create configured logger based on the default environment configuration.
-
.logger=(logger) ⇒ Object
Set logger directly and clear the loggers cache.
Instance Method Summary collapse
- #log_event(message, &block) ⇒ Object
-
#logger ⇒ Object
Get logger object.
Class Method Details
.logger ⇒ Object
Get or Create configured logger based on the default environment configuration
29 30 31 |
# File 'lib/paypal-sdk/core/logging.rb', line 29 def logger @logger ||= Logger.new(STDERR) end |
.logger=(logger) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/paypal-sdk/core/logging.rb', line 38 def logger=(logger) @logger = logger if Config.config.mode.eql? 'live' and @logger.level == Logger::DEBUG @logger.warn "DEBUG log level not allowed in sandbox mode for security of confidential information. Changing log level to INFO..." @logger.level = Logger::INFO end end |
Instance Method Details
#log_event(message, &block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/paypal-sdk/core/logging.rb', line 19 def log_event(, &block) start_time = Time.now block.call ensure logger.info sprintf("[%.3fs] %s", Time.now - start_time, ) end |