Sha256: 50cd37d41c7212205a2e34492a007df0fab2ed886016ec9e99961eef6717bc72
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require "logger" require "singleton" require "text/sanitizer" module Imap; end module Imap::Backup class Logger include Singleton def self.logger Logger.instance.logger end def self.setup_logging(options = {}) copy = options.clone quiet = copy.delete(:quiet) verbose = copy.delete(:verbose) || [] verbose_count = count(verbose) level = case when quiet ::Logger::Severity::UNKNOWN when verbose_count >= 2 ::Logger::Severity::DEBUG else ::Logger::Severity::INFO end logger.level = level Net::IMAP.debug = (verbose_count >= 3) copy end def self.sanitize_stderr sanitizer = Text::Sanitizer.new($stdout) previous_stderr = $stderr $stderr = sanitizer yield ensure sanitizer.flush $stderr = previous_stderr end def self.count(verbose) verbose.reduce(1) { |acc, v| acc + (v ? 1 : -1) } end attr_reader :logger def initialize @logger = ::Logger.new($stdout) $stdout.sync = true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
imap-backup-14.0.0 | lib/imap/backup/logger.rb |
imap-backup-13.4.0 | lib/imap/backup/logger.rb |