Sha256: c03e8877e8aa1bc4bbb29def51e3ba8ff065aa8aff74d25b55b01f5b867b5ff5

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

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
    logger.should_receive(:formatter=).with(an_instance_of(Proc))
    logger.should_receive(:level=).and_return(Logger::DEBUG)
    logger.should_receive(:add).with(2, nil, "Yowza!")
    ::Logger.should_receive(:new).with(STDOUT).and_return(logger)

    if Syslog.const_defined?('Logger', false)
      sys_logger.should_receive(:formatter=).with(an_instance_of(Proc))
      sys_logger.should_receive(:level=).with(Logger::DEBUG)
      sys_logger.should_receive(:add).with(Logger::WARN, 'Yowza!', 'flapjack')
      Syslog.const_get('Logger', false).should_receive(:new).with('flapjack').and_return(sys_logger)
    else
      Syslog.should_receive(:open).with('flapjack',
        (Syslog::Constants::LOG_PID | Syslog::Constants::LOG_CONS),
         Syslog::Constants::LOG_USER).and_return(syslog)
      Syslog.should_receive(:mask=).with(Syslog::LOG_UPTO(Syslog::Constants::LOG_WARNING))
      Syslog.should_receive(:log).with(Syslog::Constants::LOG_WARNING, /\[WARN\] :: spec :: %s/, "Yowza!")
      Syslog.should_receive(:close)
    end

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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flapjack-0.7.29 spec/lib/flapjack/logger_spec.rb
flapjack-0.7.28 spec/lib/flapjack/logger_spec.rb