|
16 | 16 |
|
17 | 17 | using System;
|
18 | 18 | using System.Collections.Generic;
|
| 19 | +using System.Diagnostics; |
19 | 20 | using System.IO;
|
20 |
| -using System.Text; |
21 | 21 | using System.Net.Sockets;
|
22 |
| -using System.Diagnostics; |
23 | 22 | using System.Reflection;
|
| 23 | +using System.Text; |
24 | 24 | using MsgPack;
|
25 | 25 | using MsgPack.Serialization;
|
26 | 26 |
|
@@ -154,26 +154,26 @@ public void UnpackTo(Unpacker unpacker, object collection)
|
154 | 154 |
|
155 | 155 | internal class FluentdEmitter
|
156 | 156 | {
|
157 |
| - private static DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); |
158 | 157 | private readonly Packer packer;
|
159 | 158 | private readonly SerializationContext serializationContext;
|
160 | 159 | private readonly Stream destination;
|
161 | 160 |
|
162 | 161 | public void Emit(DateTime timestamp, string tag, IDictionary<string, object> data)
|
163 | 162 | {
|
164 |
| - long unixTimestamp = timestamp.ToUniversalTime().Subtract(unixEpoch).Ticks / 10000000; |
165 | 163 | this.packer.PackArrayHeader(3);
|
166 | 164 | this.packer.PackString(tag, Encoding.UTF8);
|
167 |
| - this.packer.Pack((ulong)unixTimestamp); |
| 165 | + this.packer.PackEventTime(timestamp); |
168 | 166 | this.packer.Pack(data, serializationContext);
|
169 | 167 | this.destination.Flush(); // Change to packer.Flush() when packer is upgraded
|
170 | 168 | }
|
171 | 169 |
|
172 | 170 | public FluentdEmitter(Stream stream)
|
173 | 171 | {
|
174 | 172 | this.destination = stream;
|
175 |
| - this.packer = Packer.Create(destination); |
176 |
| - var embeddedContext = new SerializationContext(this.packer.CompatibilityOptions); |
| 173 | + |
| 174 | + // PackerCompatibilityOptions.ProhibitExtendedTypeObjects must be turned off in order to use the PackExtendedTypeValue method |
| 175 | + this.packer = Packer.Create(destination, Packer.DefaultCompatibilityOptions & ~PackerCompatibilityOptions.ProhibitExtendedTypeObjects); |
| 176 | + var embeddedContext = new SerializationContext(this.packer.CompatibilityOptions); |
177 | 177 | embeddedContext.Serializers.Register(new OrdinaryDictionarySerializer(embeddedContext, null));
|
178 | 178 | this.serializationContext = new SerializationContext(PackerCompatibilityOptions.PackBinaryAsRaw);
|
179 | 179 | this.serializationContext.Serializers.Register(new OrdinaryDictionarySerializer(this.serializationContext, embeddedContext));
|
|
0 commit comments