Sha256: 035fabeb20452bc9c92820ea6bf826d043a54cf5e38bebddde5e165551c37076

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

require 'logstash-logger'

describe LogStashLogger::MultiLogger do
  include_context 'device'

  # Create a MultiLogger writing to both STDOUT and a StringIO
  subject { multi_logger }

  it { is_expected.to be_a LogStashLogger::MultiLogger }

  it "has multiple loggers" do
    expect(subject.loggers.count).to eq(2)
  end

  it "has one logger per output" do
    expect(subject.loggers[0].device).to be_a LogStashLogger::Device::Stdout
    expect(subject.loggers[1].device).to be_a LogStashLogger::Device::IO
  end

  it "allows a different formatter for each logger" do
    expect(subject.loggers[0].formatter).to be_a ::Logger::Formatter
    expect(subject.loggers[1].formatter).to be_a LogStashLogger::Formatter::JsonLines
  end

  it "logs to all loggers" do
    subject.loggers.each do |logger|
      expect(logger).to receive(:info).with("test")
    end

    multi_logger.info("test")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-logger-0.15.0 spec/multi_logger_spec.rb
logstash-logger-0.14.1 spec/multi_logger_spec.rb