require 'rspec'
require 'logger'
require 'mono_logger'
require 'logging'

module BufferedLogger
  # returns the log as a string
  def log_string
    @test_log_buffer.string
  end

  def logger
    @test_logger
  end
end

RSpec.configure do |c|
  c.include(BufferedLogger)

  c.before do
    @test_log_buffer = StringIO.new
    @test_logger = Logging.logger(@test_log_buffer)
    allow(MonoLogger).to receive(:new).and_return(@test_logger)
    allow(Logging).to receive(:logger).and_return(@test_logger)
    allow(Logger).to receive(:new).and_return(@test_logger)
  end

  c.after do |example|
    # Print logs if the test failed
    unless example.exception.nil?
      STDERR.write("\nTest Failed: '#{example.full_description}'\nTest Logs:\n#{@test_log_buffer.string}\n")
    end
  end
end

require 'rspec'
require 'logger'
require 'logging'

module BufferedLogger
  # returns the log as a string
  def log_string
    @test_log_buffer.string
  end

  def logger
    @test_logger
  end
end

RSpec.configure do |c|
  c.include(BufferedLogger)

  c.before do
    @test_log_buffer = StringIO.new
    @test_logger = Logging.logger(@test_log_buffer)
    allow(Logging).to receive(:logger).and_return(@test_logger)
    allow(Logger).to receive(:new).and_return(@test_logger)
  end

  c.after do |example|
    # Print logs if the test failed
    unless example.exception.nil?
      STDERR.write("\nTest Failed: '#{example.full_description}'\nTest Logs:\n#{@test_log_buffer.string}\n")
    end
  end
end

Switch bosh-monitor to use Logging instead of MonoLogger
Switch bosh-monitor to use Logging instead of MonoLogger

[#81611698]

Signed-off-by: Karl Isenberg <ad8fead3baba6d58cb6c266b80834d1b78f48a29@pivotal.io>
