Rev | Line | |
---|
[391] | 1 | using System;
|
---|
| 2 | using AllocsFixes.JSON;
|
---|
| 3 | using JetBrains.Annotations;
|
---|
| 4 | using UnityEngine;
|
---|
| 5 | using Webserver.UrlHandlers;
|
---|
| 6 |
|
---|
| 7 | namespace 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.