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 <falls-toluene.0q@icloud.com>
Co-committed-by: witek <falls-toluene.0q@icloud.com>
(cherry picked from commit 3edf0f2ff9d6793d7441591f15dd309fef9871f5)
This commit is contained in:
witek 2024-07-31 19:04:04 +00:00 committed by Dev
parent a52c81e270
commit 59308604fa
3 changed files with 6 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import path from "node:path";
import crypto from "node:crypto"; import crypto from "node:crypto";
import fs from "node:fs"; import fs from "node:fs";
import { promisify } from "node:util"; 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<void>; protected writeFilePromisify: (path: fs.PathLike, data: string, options?: any) => Promise<void>;
constructor(protected asyncQueue: IAsyncQueue) { constructor(protected asyncQueue: IAsyncQueue) {
this.filePath = `${this.getFilePath()}${this.getFileName()}`; this.filePath = path.join(this.getFilePath(), this.getFileName());
this.writeFilePromisify = promisify(fs.writeFile); this.writeFilePromisify = promisify(fs.writeFile);
this.showDebugInConsole = globalThis.G_DEBUG_CONFIGURATION; this.showDebugInConsole = globalThis.G_DEBUG_CONFIGURATION;
if (!fs.existsSync(this.getFilePath())) { if (!fs.existsSync(this.getFilePath())) {

View File

@ -1,3 +1,4 @@
import path from "node:path";
import { IAsyncQueue } from "@spt/models/spt/utils/IAsyncQueue"; import { IAsyncQueue } from "@spt/models/spt/utils/IAsyncQueue";
import { AbstractWinstonLogger } from "@spt/utils/logging/AbstractWinstonLogger"; import { AbstractWinstonLogger } from "@spt/utils/logging/AbstractWinstonLogger";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
@ -21,7 +22,7 @@ export class WinstonMainLogger extends AbstractWinstonLogger {
} }
protected getFilePath(): string { protected getFilePath(): string {
return "./user/logs/"; return path.join("user" ,"logs");
} }
protected getFileName(): string { protected getFileName(): string {

View File

@ -1,3 +1,4 @@
import path from "node:path";
import { IAsyncQueue } from "@spt/models/spt/utils/IAsyncQueue"; import { IAsyncQueue } from "@spt/models/spt/utils/IAsyncQueue";
import { AbstractWinstonLogger } from "@spt/utils/logging/AbstractWinstonLogger"; import { AbstractWinstonLogger } from "@spt/utils/logging/AbstractWinstonLogger";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
@ -21,7 +22,7 @@ export class WinstonRequestLogger extends AbstractWinstonLogger {
} }
protected getFilePath(): string { protected getFilePath(): string {
return "./user/logs/requests/"; return path.join("user", "logs", "requests");
} }
protected getFileName(): string { protected getFileName(): string {