From be64e897b9f6105f62a0bd104bc66967656ebf68 Mon Sep 17 00:00:00 2001 From: Cj Date: Sat, 16 Mar 2024 21:03:52 +0000 Subject: [PATCH] Enable BSG logging (!262) Needs merged with: https://dev.sp-tarkov.com/SPT-AKI/Modules/pulls/96 Read details there. Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/262 Co-authored-by: Cj Co-committed-by: Cj --- project/assets/configs/core.json | 4 ++++ project/src/callbacks/ClientLogCallbacks.ts | 12 ++++++++++- project/src/models/spt/config/ICoreConfig.ts | 20 +++++++++++++++++++ .../routers/static/ClientLogStaticRouter.ts | 7 +++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/project/assets/configs/core.json b/project/assets/configs/core.json index ad6a7ec9..5e23d265 100644 --- a/project/assets/configs/core.json +++ b/project/assets/configs/core.json @@ -5,6 +5,10 @@ "serverName": "SPT Server", "profileSaveIntervalSeconds": 15, "sptFriendNickname": "SPT", + "bsgLogging": { + "verbosity": 6, + "sendToServer": false + }, "release": { "betaDisclaimerTimeoutDelay": 30 }, diff --git a/project/src/callbacks/ClientLogCallbacks.ts b/project/src/callbacks/ClientLogCallbacks.ts index ab3c772d..45d90086 100644 --- a/project/src/callbacks/ClientLogCallbacks.ts +++ b/project/src/callbacks/ClientLogCallbacks.ts @@ -2,7 +2,7 @@ import { ClientLogController } from "@spt-aki/controllers/ClientLogController"; import { ModLoadOrder } from "@spt-aki/loaders/ModLoadOrder"; import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; -import { ICoreConfig, IRelease } from "@spt-aki/models/spt/config/ICoreConfig"; +import { IBsgLogging, ICoreConfig, IRelease } from "@spt-aki/models/spt/config/ICoreConfig"; import { IClientLogRequest } from "@spt-aki/models/spt/logging/IClientLogRequest"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; import { LocalisationService } from "@spt-aki/services/LocalisationService"; @@ -54,4 +54,14 @@ export class ClientLogCallbacks return this.httpResponse.noBody(data); } + + /** + * Handle /singleplayer/enableBSGlogging + */ + + public bsgLogging(): string + { + const data: IBsgLogging = this.configServer.getConfig(ConfigTypes.CORE).bsgLogging; + return this.httpResponse.noBody(data); + } } diff --git a/project/src/models/spt/config/ICoreConfig.ts b/project/src/models/spt/config/ICoreConfig.ts index 646a963f..de65c646 100644 --- a/project/src/models/spt/config/ICoreConfig.ts +++ b/project/src/models/spt/config/ICoreConfig.ts @@ -9,6 +9,7 @@ export interface ICoreConfig extends IBaseConfig serverName: string; profileSaveIntervalSeconds: number; sptFriendNickname: string; + bsgLogging: IBsgLogging; release: IRelease; fixes: IGameFixes; features: IServerFeatures; @@ -18,6 +19,25 @@ export interface ICoreConfig extends IBaseConfig buildTime?: string; } +export interface IBsgLogging +{ + /** + * verbosity of what to log, yes I know this is backwards, but its how nlog deals with ordinals. + * complain to them about it! In all cases, better exceptions will be logged. + * WARNING: trace-info logging will quickly create log files in the megabytes. + * 0 - trace + * 1 - debug + * 2 - info + * 3 - warn + * 4 - error + * 5 - fatal + * 6 - off + */ + verbosity: number; + // Should we send the logging to the server + sendToServer: boolean; +} + export interface IRelease { // Disclaimer outlining the intended usage of bleeding edge diff --git a/project/src/routers/static/ClientLogStaticRouter.ts b/project/src/routers/static/ClientLogStaticRouter.ts index 595703a7..5472199b 100644 --- a/project/src/routers/static/ClientLogStaticRouter.ts +++ b/project/src/routers/static/ClientLogStaticRouter.ts @@ -17,6 +17,13 @@ export class ClientLogStaticRouter extends StaticRouter { return this.clientLogCallbacks.releaseNotes(); }), + new RouteAction( + "/singleplayer/enableBSGlogging", + (url: string, info: any, sessionID: string, output: string) => + { + return this.clientLogCallbacks.bsgLogging(); + }, + ), ]); } }