From 3edf0f2ff9d6793d7441591f15dd309fef9871f5 Mon Sep 17 00:00:00 2001 From: witek Date: Wed, 31 Jul 2024 19:04:04 +0000 Subject: [PATCH] Fix logs paths (!390) When compiled natively to linux, logfiles are saved in main SPT folder instead of default location. It's caused by file paths being hardcoded as text. This patch fixes logs location on linux build. Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/390 Co-authored-by: witek Co-committed-by: witek --- project/src/utils/logging/AbstractWinstonLogger.ts | 3 ++- project/src/utils/logging/WinstonMainLogger.ts | 3 ++- project/src/utils/logging/WinstonRequestLogger.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/project/src/utils/logging/AbstractWinstonLogger.ts b/project/src/utils/logging/AbstractWinstonLogger.ts index 29969bf2..bb3faf6d 100644 --- a/project/src/utils/logging/AbstractWinstonLogger.ts +++ b/project/src/utils/logging/AbstractWinstonLogger.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import crypto from "node:crypto"; import fs from "node:fs"; import { promisify } from "node:util"; @@ -34,7 +35,7 @@ export abstract class AbstractWinstonLogger implements ILogger { protected writeFilePromisify: (path: fs.PathLike, data: string, options?: any) => Promise; constructor(protected asyncQueue: IAsyncQueue) { - this.filePath = `${this.getFilePath()}${this.getFileName()}`; + this.filePath = path.join(this.getFilePath(), this.getFileName()); this.writeFilePromisify = promisify(fs.writeFile); this.showDebugInConsole = globalThis.G_DEBUG_CONFIGURATION; if (!fs.existsSync(this.getFilePath())) { diff --git a/project/src/utils/logging/WinstonMainLogger.ts b/project/src/utils/logging/WinstonMainLogger.ts index 091ac67d..1f59bfc6 100644 --- a/project/src/utils/logging/WinstonMainLogger.ts +++ b/project/src/utils/logging/WinstonMainLogger.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import { IAsyncQueue } from "@spt/models/spt/utils/IAsyncQueue"; import { AbstractWinstonLogger } from "@spt/utils/logging/AbstractWinstonLogger"; import { inject, injectable } from "tsyringe"; @@ -21,7 +22,7 @@ export class WinstonMainLogger extends AbstractWinstonLogger { } protected getFilePath(): string { - return "./user/logs/"; + return path.join("user" ,"logs"); } protected getFileName(): string { diff --git a/project/src/utils/logging/WinstonRequestLogger.ts b/project/src/utils/logging/WinstonRequestLogger.ts index fa4472e4..526b61a6 100644 --- a/project/src/utils/logging/WinstonRequestLogger.ts +++ b/project/src/utils/logging/WinstonRequestLogger.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import { IAsyncQueue } from "@spt/models/spt/utils/IAsyncQueue"; import { AbstractWinstonLogger } from "@spt/utils/logging/AbstractWinstonLogger"; import { inject, injectable } from "tsyringe"; @@ -21,7 +22,7 @@ export class WinstonRequestLogger extends AbstractWinstonLogger { } protected getFilePath(): string { - return "./user/logs/requests/"; + return path.join("user", "logs", "requests"); } protected getFileName(): string {