source: binary-improvements/MapRendering/Web/SSE/EventLog.cs@ 442

Last change on this file since 442 was 369, checked in by alloc, 3 years ago

Preparations for A20 release
Changes usage of "SteamID" to "UserID" in console commands
Also changes a bunch of the WebAPI stuff to show / use UserIDs

File size: 1.0 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}";
14 string uptime = _uptime.ToString ();
15 string message = _plainMsg;
[367]16
17 JSONObject data = new JSONObject ();
18 data.Add ("msg", new JSONString (message));
19 data.Add ("type", new JSONString (_type.ToStringCached ()));
20 data.Add ("trace", new JSONString (_trace));
21 data.Add ("date", new JSONString (date));
22 data.Add ("time", new JSONString (time));
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.