source: binary-improvements2/WebServer/src/SSE/EventLog.cs@ 400

Last change on this file since 400 was 391, checked in by alloc, 2 years ago

Major refactoring/cleanup

File size: 908 bytes
Line 
1using System;
2using AllocsFixes.JSON;
3using JetBrains.Annotations;
4using UnityEngine;
5using Webserver.UrlHandlers;
6
7namespace Webserver.SSE {
8 [UsedImplicitly]
9 public class EventLog : AbsEvent {
10 public EventLog (SseHandler _parent) : base (_parent, _name: "log") {
11 Log.LogCallbacksExtended += LogCallback;
12 }
13
14 private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
15 string isotime = _timestamp.ToString ("o");
16 string uptime = _uptime.ToString ();
17
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);
26 }
27 }
28}
Note: See TracBrowser for help on using the repository browser.