Module: Paid::Tracing::Logging
- Defined in:
- lib/paid_ruby/tracing/logging.rb
Overview
Provides a central logger for the gem. The log level can be configured via the PAID_LOG_LEVEL environment variable. Supported levels are DEBUG, INFO, WARN, ERROR, FATAL. If the variable is not set, the level defaults to FATAL to suppress output.
Class Method Summary collapse
Class Method Details
.logger ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/paid_ruby/tracing/logging.rb', line 12 def self.logger @logger ||= begin log_level_str = ENV["PAID_LOG_LEVEL"]&.upcase level = if log_level_str && Logger.const_defined?(log_level_str) Logger.const_get(log_level_str) else # Default to a level that shows no logs unless explicitly configured. Logger::FATAL end logger = Logger.new($stdout) logger.level = level logger.formatter = proc do |severity, _datetime, _progname, msg| "[Paid SDK] #{severity}: #{msg}\n" end logger end end |