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-1.2.1rc1 spec/lib/flapjack/logger_spec.rb
flapjack-1.2.0 spec/lib/flapjack/logger_spec.rb
flapjack-0.9.6 spec/lib/flapjack/logger_spec.rb
flapjack-1.2.0rc2 spec/lib/flapjack/logger_spec.rb
flapjack-1.2.0rc1 spec/lib/flapjack/logger_spec.rb
flapjack-0.9.5 spec/lib/flapjack/logger_spec.rb
flapjack-0.9.4 spec/lib/flapjack/logger_spec.rb
flapjack-1.1.0 spec/lib/flapjack/logger_spec.rb
flapjack-1.0.0 spec/lib/flapjack/logger_spec.rb
flapjack-1.0.0rc6 spec/lib/flapjack/logger_spec.rb
flapjack-1.0.0rc5 spec/lib/flapjack/logger_spec.rb
flapjack-0.9.3 spec/lib/flapjack/logger_spec.rb
flapjack-1.0.0rc3 spec/lib/flapjack/logger_spec.rb
flapjack-1.0.0rc2 spec/lib/flapjack/logger_spec.rb
flapjack-0.9.2 spec/lib/flapjack/logger_spec.rb
flapjack-0.9.1 spec/lib/flapjack/logger_spec.rb
flapjack-1.0.0rc1 spec/lib/flapjack/logger_spec.rb
flapjack-0.9.0 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.12 spec/lib/flapjack/logger_spec.rb
flapjack-0.8.11 spec/lib/flapjack/logger_spec.rb