Sha256: 397ef6b358f764310bc7856fcf5f6a15728ff943fff4d0742708cc198005c149
Contents?: true
Size: 1.48 KB
Versions: 7
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true module Hubspot # To hold Hubspot configuration class Config attr_accessor :access_token, :portal_id, :client_secret, :logger, :log_level, :timeout, :open_timeout, :read_timeout, :write_timeout def initialize @access_token = nil @portal_id = nil @client_secret = nil @logger = initialize_logger @log_level = determine_log_level apply_log_level end # Apply the log level to the logger def apply_log_level @logger.level = @log_level end private # Initialize the default logger def initialize_logger Logger.new($stdout) end # Map string values from environment variables to Logger constants # rubocop:disable Metrics/MethodLength def determine_log_level env_log_level = ENV['HUBSPOT_LOG_LEVEL'] || default_log_level case env_log_level.to_s.upcase when 'DEBUG' Logger::DEBUG when 'INFO' Logger::INFO when 'WARN' Logger::WARN when 'ERROR' Logger::ERROR when 'FATAL' Logger::FATAL else Logger::INFO # Default to INFO if unrecognized end end # rubocop:enable Metrics/MethodLength # Set the default log level based on environment def default_log_level if defined?(Rails) && Rails.env.test? 'FATAL' # Default to FATAL in test environments else 'INFO' # Default to INFO in normal usage end end end end
Version data entries
7 entries across 7 versions & 1 rubygems