Sha256: 1e65851ab44d7dfa9971ef51ace39fe83a50df768136312916795814979c9e15

Contents?: true

Size: 909 Bytes

Versions: 33

Compression:

Stored size: 909 Bytes

Contents

module Zookeeper
  TEST_LOG_PATH = File.expand_path('../../../test.log', __FILE__)

  def self.setup_test_logger
    log =
      if (ENV['ZOOKEEPER_DEBUG'] || ENV['ZKRB_DEBUG'])
        ::Logger.new(STDERR)
      else
        ::Logger.new(TEST_LOG_PATH)
      end

    log.level = ::Logger::DEBUG

    Zookeeper::Logger.wrapped_logger = log
  end
end

Zookeeper.setup_test_logger

module SpecGlobalLogger
  extend self

  def logger
    @spec_global_logger ||= Zookeeper::Logger::ForwardingLogger.for(Zookeeper::Logger.wrapped_logger, 'spec')
  end

  # sets the log level to FATAL for the duration of the block
  def mute_logger
    zk_log = Zookeeper::Logger.wrapped_logger

    orig_level, zk_log.level = zk_log.level, ::Logger::FATAL
    orig_zk_level, Zookeeper.debug_level = Zookeeper.debug_level, Zookeeper::Constants::ZOO_LOG_LEVEL_ERROR
    yield
  ensure
    zk_log.level = orig_zk_level
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
zookeeper-1.5.5 spec/support/00_logging.rb
zookeeper-1.5.5-java spec/support/00_logging.rb
zookeeper-1.5.4 spec/support/00_logging.rb
zookeeper-1.5.4-java spec/support/00_logging.rb
zookeeper-1.5.3 spec/support/00_logging.rb
zookeeper-1.5.3-java spec/support/00_logging.rb
zookeeper-ng-1.5.2.1 spec/support/00_logging.rb
zookeeper-ng-1.5.2.1-java spec/support/00_logging.rb
zookeeper-1.5.1-java spec/support/00_logging.rb
zookeeper-1.5.1 spec/support/00_logging.rb
zookeeper-1.5.0-java spec/support/00_logging.rb
zookeeper-1.5.0 spec/support/00_logging.rb
zookeeper-ng-1.5 spec/support/00_logging.rb
zookeeper-1.4.11 spec/support/00_logging.rb
zookeeper-1.4.11-java spec/support/00_logging.rb
zookeeper-1.4.10 spec/support/00_logging.rb
zookeeper-1.4.10-java spec/support/00_logging.rb
zookeeper-1.4.9 spec/support/00_logging.rb
zookeeper-1.4.9-java spec/support/00_logging.rb
zookeeper-1.4.8 spec/support/00_logging.rb