Sha256: 633e6842bc83bab0c713fef5a72b86a0384ecaf49e66e02e018b4987faefb4c5

Contents?: true

Size: 985 Bytes

Versions: 35

Compression:

Stored size: 985 Bytes

Contents

require 'spec_helper'

describe CopyTunerClient::PrefixedLogger do
  let(:output_logger) { FakeLogger.new }
  let(:prefix) { "** NOTICE:" }
  let(:thread_info) { "[P:#{Process.pid}] [T:#{Thread.current.object_id}]" }
  subject { CopyTunerClient::PrefixedLogger.new(prefix, output_logger) }

  it "provides the prefix" do
    expect(subject.prefix).to eq(prefix)
  end

  it "provides the logger" do
    expect(subject.original_logger).to eq(output_logger)
  end

  [:debug, :info, :warn, :error, :fatal].each do |level|
    it "prefixes #{level} log messages" do
      message = 'hello'
      subject.send(level, message)

      expect(output_logger).to have_entry(level, "#{prefix} #{thread_info} #{message}")
    end
  end

  it "calls flush for a logger that responds to flush" do
    expect(output_logger).to receive(:flush)

    subject.flush
  end

  it "doesn't call flush for a logger that doesn't respond to flush" do
    expect { subject.flush }.not_to raise_error
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
copy_tuner_client-0.19.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.18.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.17.1 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.16.3 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.16.2 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.16.1 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.16.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.15.1 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.15.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.14.2 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.14.1 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.14.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.13.6 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.13.5 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.13.3 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.13.2 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.13.1 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.13.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.12.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.11.0 spec/copy_tuner_client/prefixed_logger_spec.rb