Sha256: 001caf6f1b06034268ffa8400265d7c6cce433d231825ff25480e4b2b5aa43f1
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
require 'helper' class LogTest < UnitTest def setup super Jersey.logger.stream = StringIO.new end def test_log_json logger = Jersey::JSONLogger.new(stream: StringIO.new) logger.log(foo: "bar") logdata = JSON.parse(logger.stream.string) assert_equal('bar', logdata['foo']) end def test_log_nothing_logs_time Jersey.log() logdata = Logfmt.parse(logs) assert(logdata['now'], 'must log time') end def test_log_hash Jersey.log(foo: 'bar') logdata = Logfmt.parse(logs) assert_equal('bar', logdata['foo']) assert(logdata['now'], 'must log time') end def test_log_error begin raise "boom!" rescue => e Jersey.log(e) loglines = logs.lines logdata = Logfmt.parse(loglines[0]) assert_equal('boom!', logdata['message']) assert_equal(e.object_id, logdata['id']) assert(logdata['now'], 'must log time') logdata = Logfmt.parse(loglines[1]) assert_equal(1, logdata['line_number']) assert_equal(e.object_id, logdata['id']) logdata = Logfmt.parse(loglines[2]) assert_equal(2, logdata['line_number']) assert_equal(e.object_id, logdata['id']) logdata = Logfmt.parse(loglines.last) assert_equal(10, logdata['line_number']) assert_equal(e.object_id, logdata['id']) assert_equal(11, loglines.size) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jersey-0.2.0 | test/log_test.rb |
jersey-0.1.0 | test/log_test.rb |
jersey-0.0.3 | test/log_test.rb |