Sha256: 062757b6ec0d9dc1e963e9c40a6860591abb512ac2eb4a66a8087bcc40a3a4b2
Contents?: true
Size: 1.23 KB
Versions: 7
Compression:
Stored size: 1.23 KB
Contents
require "spec_helper" describe Logtail::LogEntry do let(:time) { Time.utc(2021, 06, 11, 12, 0, 0) } describe "#to_msgpack" do it "should encode properly with an event and context" do event = { message: "event_message", event: { event_type: { a: 1 } } } context = {custom: {a: "b"}} log_entry = described_class.new("INFO", time, nil, "log message", context, event) msgpack = log_entry.to_msgpack expect(msgpack).to start_with("\x85\xA5level\xA4INFO\xA2dt\xBB2021-06-11T12:00:00.000000Z".force_encoding("ASCII-8BIT")) end end describe "#to_hash" do it "should include runtime context information" do log_entry = Logtail::Logger::PassThroughFormatter.new.call("INFO", time, "", "log message") hash = log_entry.to_hash expect(hash[:context]).to_not be_nil expect(hash[:context][:runtime]).to_not be_nil expect(hash[:context][:runtime][:file]).to end_with('/spec/logtail/log_entry_spec.rb') expect(hash[:context][:runtime][:line]).to be(25) expect(hash[:context][:runtime][:frame_label]).to_not be_nil expect(hash[:context][:runtime][:frame_label].encoding.to_s).to eq('UTF-8') end end end
Version data entries
7 entries across 7 versions & 1 rubygems