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
RevLine 
[367]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") {
[369]8 Log.LogCallbacksExtended += LogCallback;
[367]9 }
10
[369]11 private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
[382]12 string isotime = _timestamp.ToString ("o");
[369]13 string uptime = _uptime.ToString ();
14 string message = _plainMsg;
[367]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));
[382]20 data.Add ("isotime", new JSONString (isotime));
[367]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.