Sha256: eb23ee134f977ea8e01e21786cb8b3b453f44234b5bd80ba5c00ad8303a89949
Contents?: true
Size: 717 Bytes
Versions: 6
Compression:
Stored size: 717 Bytes
Contents
# frozen_string_literal: true require 'logger' module CzechPostB2bClient class Logger attr_reader :target_logger, :min_log_level LEVELS = { debug: 0, info: 1, error: 2 }.freeze def initialize(configuration) @target_logger = configuration.logger @min_log_level = configuration.log_messages_at_least_as end def log(original_level, message) target_logger.send(modified_log_level(original_level), message) end LEVELS.each_key do |level| define_method(level) { |message| log(level, message) } end private def modified_log_level(original_level) LEVELS[original_level] > LEVELS[min_log_level] ? original_level : min_log_level end end end
Version data entries
6 entries across 6 versions & 1 rubygems