diff --git a/src/main/decorators/log.decorator.ts b/src/main/decorators/log.decorator.ts deleted file mode 100644 index 9c87f932..00000000 --- a/src/main/decorators/log.decorator.ts +++ /dev/null @@ -1,67 +0,0 @@ -import log from "electron-log"; -import { isPromise } from "../../shared/helpers/promise.helpers"; -import { tryit } from "../../shared/helpers/error.helpers"; - -type LogOptions = { - logInput?: boolean; - logOutput?: boolean; - logArgs?: boolean; -}; - -const stringifyArgs = (args: unknown[]) => { - return args?.map(a => JSON.stringify(a)).join(', '); -}; - -const logInfo = (message: string, propertyKey: string, args: unknown[], logArgs: boolean, result: unknown) => { - log.info(`[${message}] ${propertyKey}(${logArgs ? stringifyArgs(args) : ''})`, result); -}; - -const logError = (propertyKey: string, args: unknown[], logArgs: boolean, error: unknown) => { - log.error(`[ERROR] ${propertyKey}(${logArgs ? stringifyArgs(args) : ''})`, error); - throw error; -}; - -export function Log(options?: LogOptions){ - - const logInput = options?.logInput ?? false; - const logOutput = options?.logOutput ?? true; - const logArgs = options?.logArgs ?? true; - - return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => { - const originalMethod = descriptor.value; - - descriptor.value = function(...args: unknown[]) { - - if (logInput) { - logInfo('INPUT', propertyKey, args, logArgs, null); - } - - const outcome = tryit(() => originalMethod.apply(this, args)); - - if (isPromise(outcome)) { - return outcome.then(({ result, error }) => { - - if (error) { - logError(propertyKey, args, logArgs, error); - } - if (logOutput) { - logInfo('OUTPUT', propertyKey, args, logArgs, result); - } - return result; - }); - } - - const { result, error } = outcome; - - if (error) { - logError(propertyKey, args, logArgs, error); - } - - if (logOutput) { - logInfo('OUTPUT', propertyKey, args, logArgs, result); - } - - return result; - }; - }; -} diff --git a/src/main/helpers/fs.helpers.ts b/src/main/helpers/fs.helpers.ts index a3df7860..2312e1ff 100644 --- a/src/main/helpers/fs.helpers.ts +++ b/src/main/helpers/fs.helpers.ts @@ -3,7 +3,6 @@ import { access, mkdir, readdir, lstat, readlink } from "fs/promises"; import path from "path"; import { Observable, concatMap, from } from "rxjs"; import log from "electron-log"; -import { BsmException } from "shared/models/bsm-exception.model"; import crypto from "crypto"; import { execSync } from "child_process"; import { tryit } from "../../shared/helpers/error.helpers"; @@ -181,7 +180,7 @@ export function isSubdirectory(parent: string, child: string): boolean { export async function copyDirectoryWithJunctions(src: string, dest: string, options?: CopyOptions): Promise { if (isSubdirectory(src, dest)) { - throw { message: `Cannot copy directory '${src}' into itself '${dest}'.`, code: "COPY_TO_SUBPATH" } as BsmException; + throw new CustomError(`Cannot copy directory '${src}' into itself '${dest}'.`, "COPY_TO_SUBPATH"); } await ensureDir(dest); diff --git a/src/main/services/additional-content/maps/song-cache.service.ts b/src/main/services/additional-content/maps/song-cache.service.ts index 751b55d8..26fad375 100644 --- a/src/main/services/additional-content/maps/song-cache.service.ts +++ b/src/main/services/additional-content/maps/song-cache.service.ts @@ -19,7 +19,6 @@ export class SongCacheService { private readonly mapsInfoCache: JsonCache; private constructor(){ - console.log(this.MAPS_INFO_CACHE_PATH); this.mapsInfoCache = new JsonCache(this.MAPS_INFO_CACHE_PATH); }