0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
DrakiaXYZ 4b0ebbe597 Send plugin errors to the server console (!35)
- Implement the models/helpers required to send console messages to the server console
- Implement sending plugin errors on startup to the server console
- Remove an unused variable and incorrect comment from PluginErrorNotifierPatch

Example output:
![Example](https://i.imgur.com/c0XBYLm.png)

Depends on changes in SPT-AKI/Server#160

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#35
Reviewed-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2023-10-27 18:46:56 +00:00

58 lines
1.7 KiB
C#

using Aki.Common.Http;
using Aki.Common.Models.Logging;
using System;
namespace Aki.Common.Utils
{
public static class ServerLog
{
public static void Custom(
string source,
string message,
EServerLogTextColor color = EServerLogTextColor.White,
EServerLogBackgroundColor backgroundColor = EServerLogBackgroundColor.Default)
{
Log(source, message, EServerLogLevel.Custom, color, backgroundColor);
}
public static void Error(string source, string message)
{
Log(source, message, EServerLogLevel.Error);
}
public static void Warn(string source, string message)
{
Log(source, message, EServerLogLevel.Warn);
}
public static void Success(string source, string message)
{
Log(source, message, EServerLogLevel.Success);
}
public static void Info(string source, string message)
{
Log(source, message, EServerLogLevel.Info);
}
public static void Log(
string source,
string message,
EServerLogLevel level = EServerLogLevel.Info,
EServerLogTextColor color = EServerLogTextColor.White,
EServerLogBackgroundColor backgroundColor = EServerLogBackgroundColor.Default)
{
ServerLogRequest request = new ServerLogRequest
{
Source = source,
Message = message,
Level = level,
Color = color,
BackgroundColor = backgroundColor
};
RequestHandler.PostJson("/singleplayer/log", Json.Serialize(request));
}
}
}