From 7389be4472153292317b93a21fcb7d2e137d4d87 Mon Sep 17 00:00:00 2001 From: Ziwei Wang Date: Fri, 1 Dec 2023 14:29:59 -0500 Subject: [PATCH] Refactor: use logger from the lib --- server/src/embedded-languages/documents-manager.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/embedded-languages/documents-manager.ts b/server/src/embedded-languages/documents-manager.ts index 531466e4..71620f86 100644 --- a/server/src/embedded-languages/documents-manager.ts +++ b/server/src/embedded-languages/documents-manager.ts @@ -7,7 +7,7 @@ import { randomUUID } from 'crypto' import path from 'path' import fs from 'fs' -import logger from 'winston' +import { logger } from '../lib/src/utils/OutputLogger' import { type EmbeddedLanguageDocInfos, type EmbeddedLanguageType } from '../lib/src/types/embedded-languages' import { type EmbeddedLanguageDoc } from './utils' @@ -45,7 +45,7 @@ export default class EmbeddedLanguageDocsManager { const newPathToEmbeddedLanguageDocsFolder = path.join(newStoragePath, EMBEDDED_DOCUMENTS_FOLDER) fs.mkdir(newPathToEmbeddedLanguageDocsFolder, { recursive: true }, (err) => { if (err !== null) { - logger.error('Failed to create embedded language documents folder:', err) + logger.error(`Failed to create embedded language documents folder: ${JSON.stringify(err)}`) } resolve() }) @@ -58,7 +58,7 @@ export default class EmbeddedLanguageDocsManager { const oldPathToEmbeddedLanguageDocsFolder = path.join(this._storagePath, EMBEDDED_DOCUMENTS_FOLDER) fs.rmdir(oldPathToEmbeddedLanguageDocsFolder, { recursive: true }, (err) => { if (err !== null) { - logger.error('Failed to remove embedded language documents folder:', err) + logger.error(`Failed to remove embedded language documents folder: ${JSON.stringify(err)}`) } resolve() }) @@ -102,7 +102,7 @@ export default class EmbeddedLanguageDocsManager { async saveEmbeddedLanguageDoc ( embeddedLanguageDoc: EmbeddedLanguageDoc ): Promise { - logger.debug(`Save embedded document (${embeddedLanguageDoc.language}) for`, embeddedLanguageDoc.originalUri) + logger.debug(`Save embedded document (${embeddedLanguageDoc.language}) for ${embeddedLanguageDoc.originalUri}`) const pathToEmbeddedLanguageDoc = this.getPathToEmbeddedLanguageDoc(embeddedLanguageDoc) if (pathToEmbeddedLanguageDoc === undefined) { return @@ -118,12 +118,12 @@ export default class EmbeddedLanguageDocsManager { } this.registerEmbeddedLanguageDocInfos(embeddedLanguageDoc.originalUri, embeddedLanguageDocInfos) }).catch((err) => { - logger.error('Failed to create embedded document:', err) + logger.error(`Failed to create embedded document: ${err}`) }) } async deleteEmbeddedLanguageDocs (originalUriString: string): Promise { - logger.debug('Delete embedded documents for', originalUriString) + logger.debug(`Delete embedded documents for ${originalUriString}`) const embeddedLanguageDocs = this.embeddedLanguageDocsInfos.get(originalUriString) ?? {} await Promise.all(Object.values(embeddedLanguageDocs).map(async ({ uri }) => { await new Promise((resolve, reject) => { @@ -135,7 +135,7 @@ export default class EmbeddedLanguageDocsManager { })).then(() => { this.embeddedLanguageDocsInfos.delete(originalUriString) }).catch((err) => { - logger.error('Failed to delete embedded document:', err) + logger.error(`Failed to delete embedded document: ${err}`) }) }