Ignore:
Timestamp:
Aug 18, 2023, 12:08:10 PM (15 months ago)
Author:
alloc
Message:

21.1.16.2 WebServer release
Added "id"s to messages in log API / event
Added "baseUrl" to mods API for WebMods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TFP-WebServer/WebServer/src/SSE/EventLog.cs

    r425 r467  
    1 using System;
    21using JetBrains.Annotations;
    3 using UnityEngine;
    42using Utf8Json;
    53using Webserver.UrlHandlers;
    6 using Webserver.WebAPI;
     4using Webserver.WebAPI.APIs;
    75
    86namespace Webserver.SSE {
     
    108        public class EventLog : AbsEvent {
    119                public EventLog (SseHandler _parent) : base (_parent, _name: "log") {
    12                         Log.LogCallbacksExtended += LogCallback;
     10                        LogBuffer.EntryAdded += LogCallback;
    1311                }
    1412
    15                 private static readonly byte[] jsonMsgKey = JsonWriter.GetEncodedPropertyNameWithBeginObject ("msg");
    16                 private static readonly byte[] jsonTypeKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("type");
    17                 private static readonly byte[] jsonTraceKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("trace");
    18                 private static readonly byte[] jsonIsotimeKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("isotime");
    19                 private static readonly byte[] jsonUptimeKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("uptime");
    20 
    21                 private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) {
    22                         string uptime = _uptime.ToString ();
    23 
     13                private void LogCallback (LogBuffer.LogEntry _logEntry) {
    2414                        JsonWriter writer = new JsonWriter ();
    25                        
    26                         writer.WriteRaw (jsonMsgKey);
    27                         writer.WriteString (_plainMsg);
    28                        
    29                         writer.WriteRaw (jsonTypeKey);
    30                         writer.WriteString (_type.ToStringCached ());
    31                        
    32                         writer.WriteRaw (jsonTraceKey);
    33                         writer.WriteString (_trace);
    34                        
    35                         writer.WriteRaw (jsonIsotimeKey);
    36                         JsonCommons.WriteDateTime (ref writer, _timestamp);
    37                        
    38                         writer.WriteRaw (jsonUptimeKey);
    39                         writer.WriteString (uptime);
    40                        
    41                         writer.WriteEndObject ();
     15                        LogApi.WriteLogMessageObject (ref writer, _logEntry);
    4216                       
    4317                        SendData ("logLine", writer.ToString ());
Note: See TracChangeset for help on using the changeset viewer.