Changeset 402 for binary-improvements2/WebServer/src/SSE/EventLog.cs
- Timestamp:
- Jan 27, 2023, 7:28:00 PM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/SSE/EventLog.cs
r391 r402 1 1 using System; 2 using AllocsFixes.JSON;3 2 using JetBrains.Annotations; 4 3 using UnityEngine; 4 using Utf8Json; 5 5 using Webserver.UrlHandlers; 6 6 … … 12 12 } 13 13 14 private static readonly byte[] jsonMsgKey = JsonWriter.GetEncodedPropertyNameWithBeginObject ("msg"); 15 private static readonly byte[] jsonTypeKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("type"); 16 private static readonly byte[] jsonTraceKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("trace"); 17 private static readonly byte[] jsonIsotimeKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("isotime"); 18 private static readonly byte[] jsonUptimeKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("uptime"); 19 14 20 private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) { 15 21 string isotime = _timestamp.ToString ("o"); 16 22 string uptime = _uptime.ToString (); 17 23 18 JsonObject data = new JsonObject (); 19 data.Add ("msg", new JsonString (_plainMsg)); 20 data.Add ("type", new JsonString (_type.ToStringCached ())); 21 data.Add ("trace", new JsonString (_trace)); 22 data.Add ("isotime", new JsonString (isotime)); 23 data.Add ("uptime", new JsonString (uptime)); 24 25 SendData ("logLine", data); 24 JsonWriter writer = new JsonWriter (); 25 26 writer.WriteRaw (jsonMsgKey); 27 writer.WriteString (_plainMsg); 28 29 writer.WriteRaw (jsonTypeKey); 30 writer.WriteString (_type.ToStringCached ()); 31 32 writer.WriteRaw (jsonTraceKey); 33 writer.WriteString (_trace); 34 35 writer.WriteRaw (jsonIsotimeKey); 36 writer.WriteString (isotime); 37 38 writer.WriteRaw (jsonUptimeKey); 39 writer.WriteString (uptime); 40 41 writer.WriteEndObject (); 42 43 SendData ("logLine", writer.ToString ()); 26 44 } 27 45 }
Note:
See TracChangeset
for help on using the changeset viewer.