Sha256: 6dd526600bbaff7a83e439ef700921789d48ebc3a48fb38957026edf2b50f06f

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require File.expand_path('../helper', __FILE__)

describe "syslog logger" do
  
  it "create a new logger with hostname and facility" do
    lambda {@logger = SyslogProto::Logger.new("space_station", 'test', "local0")}.should.not.raise
  end
  
  it "hostname and facility must conform to the requirements of a Packet" do
    lambda {SyslogProto::Logger.new("space station", "some shit", 'test test')}.should.raise ArgumentError
  end
  
  it "generates packets" do
    # We have to set a time so we have a consistant timestamp to check against..
    p = @logger.instance_variable_get("@packet")
    p.time = Time.now
    ts = p.generate_timestamp
    @logger.debug("vacuum tubez are operational").should.equal "<135>#{ts} space_station test: vacuum tubez are operational"
    @logger.info("firing thrusters at 13 degrees").should.equal "<134>#{ts} space_station test: firing thrusters at 13 degrees"
    @logger.notice("the hyper drive has been activated").should.equal "<133>#{ts} space_station test: the hyper drive has been activated"
    @logger.warn("meteorites incoming!").should.equal "<132>#{ts} space_station test: meteorites incoming!"
    @logger.err("vacuum tube 3 in hyper drive failed").should.equal "<131>#{ts} space_station test: vacuum tube 3 in hyper drive failed"
    @logger.crit("wing struck by a meteorite!").should.equal "<130>#{ts} space_station test: wing struck by a meteorite!"
    @logger.alert("LEAKING ATMOSPHERE").should.equal "<129>#{ts} space_station test: LEAKING ATMOSPHERE"
    @logger.emerg("LEAKING ASTRONAUTS WE ARE DONE").should.equal "<128>#{ts} space_station test: LEAKING ASTRONAUTS WE ARE DONE"
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
syslog_protocol-0.9.0 test/test_logger.rb