Sha256: 58c88377dd8817b0f3b587fa5a92d37378f7904d38b089effde1a4c4aed969d9

Contents?: true

Size: 930 Bytes

Versions: 4

Compression:

Stored size: 930 Bytes

Contents

require 'logstash-logger'

describe LogStashLogger do
  let(:program_name) { 'MyApp' }
  let(:facility) { 128 } #Syslog::LOG_LOCAL0 }

  context 'Syslog' do
    subject { LogStashLogger.new(type: :syslog, program_name: program_name, facility: facility) }
    let(:syslog) { subject.class.class_variable_get(:@@syslog) }

    it { is_expected.to be_a Syslog::Logger }

    it 'writes formatted messages to syslog' do
      expect(syslog).to receive(:log)
      subject.info('test')
    end

    it 'sets the syslog identity' do
      expect(syslog.ident).to eq(program_name)
    end

    it 'sets the default facility if supported' do
      expect(subject.facility).to eq(facility) if subject.respond_to?(:facility)
    end
  end

  context 'when logger type is a string' do
    subject { LogStashLogger.new(type: 'syslog', program_name: program_name, facility: facility) }

    it { is_expected.to be_a Syslog::Logger }
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
logstash-logger-p-0.26.1 spec/syslog_spec.rb
logstash-logger-yajl-0.27.0 spec/syslog_spec.rb
logstash-logger-0.26.1 spec/syslog_spec.rb
logstash-logger-0.26.0 spec/syslog_spec.rb