This repository has been archived on 2023-12-11. You can view files and clone it, but cannot push or open issues or pull requests.
pgls/lib/pg_ldap_sync/logger.rb
2022-12-02 14:03:45 +01:00

29 lines
537 B
Ruby

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