Sha256: 4be3c0392eb6c9b50892b11a7b7e9e4ed9ca312b9877b3ec1de672f921308197

Contents?: true

Size: 847 Bytes

Versions: 34

Compression:

Stored size: 847 Bytes

Contents

module Spec
  module LoggingHelper

    # Capture log messages from the Logging framework and make them
    # available via a @log_output instance variable. The @log_output
    # supports a readline method to access the log messags.
    #
    def capture_log_messages( opts = {} )
      from = opts.getopt(:from, 'root')
      to = opts.getopt(:to, '__rspec__')
      exclusive = opts.getopt(:exclusive, true)

      appender = Logging::Appenders[to] || Logging::Appenders::StringIo.new(to)
      logger = Logging::Logger[from]
      if exclusive
        logger.appenders = appender
      else
        logger.add_appenders(appender)
      end

      before(:all) do
        @log_output = Logging::Appenders[to]
      end

      before(:each) do
        @log_output.reset
      end
    end

  end  # module LoggingHelper
end  # module Spec

# EOF

Version data entries

34 entries across 34 versions & 5 rubygems

Version Path
TwP-logging-0.9.8.1 lib/spec/logging_helper.rb
TwP-logging-0.9.8.2 lib/spec/logging_helper.rb
TwP-logging-1.0.0 lib/spec/logging_helper.rb
TwP-logging-1.1.0 lib/spec/logging_helper.rb
TwP-logging-1.1.1 lib/spec/logging_helper.rb
TwP-logging-1.1.2 lib/spec/logging_helper.rb
TwP-logging-1.1.3 lib/spec/logging_helper.rb
TwP-logging-1.1.4 lib/spec/logging_helper.rb
TwP-logging-1.2.0 lib/spec/logging_helper.rb
TwP-logging-1.2.2 lib/spec/logging_helper.rb
pjstadig-logging-1.1.4.1 lib/spec/logging_helper.rb
logging-1.5.2 lib/spec/logging_helper.rb
logging-1.5.1 lib/spec/logging_helper.rb
logging-1.5.0 lib/spec/logging_helper.rb
logging-1.4.3 lib/spec/logging_helper.rb
sgeorgi-logging-1.4.2 lib/spec/logging_helper.rb
logging-1.4.2 lib/spec/logging_helper.rb
logging-1.4.1 lib/spec/logging_helper.rb
logging-1.4.0 lib/spec/logging_helper.rb
redcar-0.3.1dev lib/logging/lib/spec/logging_helper.rb