Sha256: a1fb29c1bbc128097e098472dce8f7ea2311ff9ea68c108b4345c4cc4dc0643e

Contents?: true

Size: 537 Bytes

Versions: 4

Compression:

Stored size: 537 Bytes

Contents

require 'logger'

module PgLdapSync
class Logger < ::Logger
  def initialize(io)
    super(io)
    @counters = {}
  end

  def add(severity, *args, &block)
    super
    return unless [Logger::FATAL, Logger::ERROR].include?(severity)
    @counters[severity] ||= block ? block.call : args.first
  end

  def had_logged?(severity)
    !!@counters[severity]
  end

  def had_errors?
    had_logged?(Logger::FATAL) || had_logged?(Logger::ERROR)
  end

  def first_error
    @counters[Logger::FATAL] || @counters[Logger::ERROR]
  end
end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
pgls-1.0.4 lib/pgls/logger.rb
pg-ldap-sync-0.5.0 lib/pg_ldap_sync/logger.rb
pgls-1.0.3 lib/pgls/logger.rb
pg-ldap-sync-0.4.0 lib/pg_ldap_sync/logger.rb