Sha256: 3eb8428e2f9254de2df3d8a118ba7e2cfbe35d1b527d8ae30ba8a86699ba66e9

Contents?: true

Size: 960 Bytes

Versions: 53

Compression:

Stored size: 960 Bytes

Contents

module RSpec
  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 messages.
    #
    def capture_log_messages( opts = {} )
      from = opts.fetch(:from, 'root')
      to = opts.fetch(:to, '__rspec__')
      exclusive = opts.fetch(: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 RSpec

if defined?  RSpec::Core::Configuration
  class RSpec::Core::Configuration
    include RSpec::LoggingHelper
  end
end

Version data entries

53 entries across 45 versions & 4 rubygems

Version Path
logging-2.4.0 lib/rspec/logging_helper.rb
logging-2.3.1 lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/lib/rspec/logging_helper.rb
logging-2.3.0 lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/lib/rspec/logging_helper.rb