source: binary-improvements2/MapRendering/Web/SSE/EventLog.cs@ 389

Last change on this file since 389 was 387, checked in by alloc, 2 years ago

Big refactoring in Web to pass around a Context instead of a bunch of individual arguments all the time

File size: 889 bytes
Line 
1using System;
2using AllocsFixes.JSON;
3using UnityEngine;
4
5namespace AllocsFixes.NetConnections.Servers.Web.SSE {
6 public class EventLog : EventBase {
7 public EventLog (SseHandler _parent) : base (_parent, _name: "log") {
8 Log.LogCallbacksExtended += LogCallback;
9 }
10
11 private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
12 string isotime = _timestamp.ToString ("o");
13 string uptime = _uptime.ToString ();
14 string message = _plainMsg;
15
16 JSONObject data = new JSONObject ();
17 data.Add ("msg", new JSONString (message));
18 data.Add ("type", new JSONString (_type.ToStringCached ()));
19 data.Add ("trace", new JSONString (_trace));
20 data.Add ("isotime", new JSONString (isotime));
21 data.Add ("uptime", new JSONString (uptime));
22
23 SendData ("logLine", data);
24 }
25 }
26}
Note: See TracBrowser for help on using the repository browser.