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

Last change on this file since 386 was 382, checked in by alloc, 2 years ago

Switched to use SpaceWizards.HttpListener

File size: 1.1 KB
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) {
12 string date = $"{_timestamp.Year:0000}-{_timestamp.Month:00}-{_timestamp.Day:00}";
13 string time = $"{_timestamp.Hour:00}:{_timestamp.Minute:00}:{_timestamp.Second:00}";
[382]14 string isotime = _timestamp.ToString ("o");
[369]15 string uptime = _uptime.ToString ();
16 string message = _plainMsg;
[367]17
18 JSONObject data = new JSONObject ();
19 data.Add ("msg", new JSONString (message));
20 data.Add ("type", new JSONString (_type.ToStringCached ()));
21 data.Add ("trace", new JSONString (_trace));
22 data.Add ("date", new JSONString (date));
23 data.Add ("time", new JSONString (time));
[382]24 data.Add ("isotime", new JSONString (isotime));
[367]25 data.Add ("uptime", new JSONString (uptime));
26
27 SendData ("logLine", data);
28 }
29 }
30}
Note: See TracBrowser for help on using the repository browser.