Sha256: 4b824c1fd07519cfae62c4aada5aa38bfadbfa61a98b886f3474f0c8704fcb68

Contents?: true

Size: 1.47 KB

Versions: 51

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'
require 'flapjack/logger'

describe Flapjack::Logger do

  let(:logger)     { double(::Logger) }

  let(:sys_logger) { double(::Logger) }
  let(:syslog)     { double(Syslog) }

  it "creates a logger logging to STDOUT and syslog" do
    expect(logger).to receive(:formatter=).with(an_instance_of(Proc))
    expect(logger).to receive(:level=).and_return(Logger::DEBUG)
    expect(logger).to receive(:add).with(2, nil, "Yowza!")
    expect(::Logger).to receive(:new).with(STDOUT).and_return(logger)

    expect(Syslog).to receive(:open).with('flapjack',
      (Syslog::Constants::LOG_PID | Syslog::Constants::LOG_CONS),
       Syslog::Constants::LOG_USER).and_return(syslog)
    expect(Syslog).to receive(:mask=).with(Syslog::LOG_UPTO(Syslog::Constants::LOG_ERR))
    expect(Syslog).to receive(:log).with(Syslog::Constants::LOG_WARNING, /\[WARN\] :: spec :: %s/, "Yowza!")
    expect(Syslog).to receive(:close)

    flogger = Flapjack::Logger.new('spec', 'level' => 'debug', 'syslog_errors' => 'true')
    flogger.warn "Yowza!"
  end

  it 'defaults to not logging via syslog' do
    expect(logger).to receive(:formatter=).with(an_instance_of(Proc))
    expect(logger).to receive(:level=).and_return(Logger::DEBUG)
    expect(logger).to receive(:add).with(2, nil, "Yowza!")
    expect(::Logger).to receive(:new).with(STDOUT).and_return(logger)

    expect(Syslog).not_to receive(:open)

    flogger = Flapjack::Logger.new('spec', 'level' => 'debug')
    flogger.warn "Yowza!"
  end

end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
flapjack-0.8.10 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.9 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.8 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.7 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.6 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.5 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.4 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.3 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.2 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.1 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.0 spec/lib/flapjack/logger_spec.rb