Skip to content

Commit

Permalink
Refactor: use logger from the lib
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonZiweiWang committed Dec 1, 2023
1 parent 4c59df3 commit 7389be4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/src/embedded-languages/documents-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
})
Expand All @@ -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()
})
Expand Down Expand Up @@ -102,7 +102,7 @@ export default class EmbeddedLanguageDocsManager {
async saveEmbeddedLanguageDoc (
embeddedLanguageDoc: EmbeddedLanguageDoc
): Promise<void> {
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
Expand All @@ -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<void> {
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<void>((resolve, reject) => {
Expand All @@ -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}`)
})
}

Expand Down

0 comments on commit 7389be4

Please sign in to comment.