Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
refactor(backend:logging): standardize logger method arguments by replacing string-based messages with structured objects
johaven4a77365fa94b
diff --git a/backend/src/applications/admin/services/admin.service.ts b/backend/src/applications/admin/services/admin.service.tsindex c9332680..2d72a8b8 100644--- a/backend/src/applications/admin/services/admin.service.ts+++ b/backend/src/applications/admin/services/admin.service.ts@@ -33,11 +33,11 @@ export class AdminService {})lastVersion = res.data?.tag_name || ''} catch (e) {- this.logger.warn(`${this.checkServerUpdateAndNotify.name} - unable to check update: ${e}`)+ this.logger.warn({ tag: this.checkServerUpdateAndNotify.name, msg: `unable to check update: ${e}` })return}if (!lastVersion.startsWith('v')) {- this.logger.warn(`${this.checkServerUpdateAndNotify.name} - unable to check version: ${lastVersion}`)+ this.logger.warn({ tag: this.checkServerUpdateAndNotify.name, msg: `unable to check version: ${lastVersion}` })return}lastVersion = lastVersion.slice(1) // remove 'v' to compare with the current version@@ -69,6 +69,6 @@ export class AdminService {this.notificationsManager.create(adminsToNotify, notification).then(() => this.cache.set(this.checkServerUpdateAndNotify.name, { version: lastVersion } satisfies ServerReleaseNotification, 0))- .catch((e: Error) => this.logger.error(`${this.checkServerUpdateAndNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.checkServerUpdateAndNotify.name, msg: `${e}` }))}}diff --git a/backend/src/applications/comments/services/comments-manager.service.ts b/backend/src/applications/comments/services/comments-manager.service.tsindex fba718de..ba1bb1d5 100644--- a/backend/src/applications/comments/services/comments-manager.service.ts+++ b/backend/src/applications/comments/services/comments-manager.service.ts@@ -50,7 +50,7 @@ export class CommentsManager {fileId = await this.getFileId(space, createCommentDto.fileId)}const commentId: number = await this.commentQueries.createComment(user.id, fileId, createCommentDto.content)- this.notify(user, fileId, space, createCommentDto.content).catch((e: Error) => this.logger.error(`${this.createComment.name} - ${e}`))+ this.notify(user, fileId, space, createCommentDto.content).catch((e: Error) => this.logger.error({ tag: this.createComment.name, msg: `${e}` }))return (await this.commentQueries.getComments(user.id, space.dbFile?.ownerId === user.id, null, commentId))[0]}@@ -114,6 +114,6 @@ export class CommentsManager {currentUrl: this.contextManager.headerOriginUrl(),content: comment})- .catch((e: Error) => this.logger.error(`${this.notify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.notify.name, msg: `${e}` }))}}diff --git a/backend/src/applications/files/adapters/files-indexer-mysql.service.ts b/backend/src/applications/files/adapters/files-indexer-mysql.service.tsindex 45cdc0e9..ae4ff85b 100644--- a/backend/src/applications/files/adapters/files-indexer-mysql.service.ts+++ b/backend/src/applications/files/adapters/files-indexer-mysql.service.ts@@ -36,7 +36,7 @@ export class FilesIndexerMySQL implements FilesIndexer {await this.db.execute(createTableFilesContent(tableName))return true} catch (e) {- this.logger.error(`${this.createIndex.name} - ${tableName} : ${e}`)+ this.logger.error({ tag: this.createIndex.name, msg: `${tableName} : ${e}` })return false}}@@ -46,7 +46,7 @@ export class FilesIndexerMySQL implements FilesIndexer {await this.db.execute(sql`DROP TABLE IF EXISTS ${sql.raw(tableName)} `)return true} catch (e) {- this.logger.error(`${this.dropIndex.name} - ${tableName} : ${e}`)+ this.logger.error({ tag: this.dropIndex.name, msg: `${tableName} : ${e}` })return false}}@@ -64,7 +64,7 @@ export class FilesIndexerMySQL implements FilesIndexer {content = VALUES(content)`)} catch (e) {- this.logger.error(`${this.insertRecord.name} - ${tableName} : ${e}`)+ this.logger.error({ tag: this.insertRecord.name, msg: `${tableName} : ${e}` })}}@@ -84,16 +84,16 @@ export class FilesIndexerMySQL implements FilesIndexer {FROM ${sql.raw(tableName)}WHERE id IN (${sql.raw(ids.join(','))})`)if (r.affectedRows !== ids.length) {- this.logger.warn(`${this.deleteRecords.name} - ${tableName} - deleted : ${r.affectedRows}/${ids.length}`)+ this.logger.warn({ tag: this.deleteRecords.name, msg: `${tableName} - deleted : ${r.affectedRows}/${ids.length}` })}} catch (e) {- this.logger.error(`${this.deleteRecords.name} - ${tableName} : ${e}`)+ this.logger.error({ tag: this.deleteRecords.name, msg: `${tableName} : ${e}` })}}async searchRecords(tableNames: string[], search: string, limit: number): Promise<FileContent[]> {const terms: string[] = analyzeTerms(search)- this.logger.debug(`${this.searchRecords.name} - convert ${search} -> ${JSON.stringify(terms)}`)+ this.logger.debug({ tag: this.searchRecords.name, msg: `convert ${search} -> ${JSON.stringify(terms)}` })if (!terms.length) {return []}@@ -141,7 +141,7 @@ export class FilesIndexerMySQL implements FilesIndexer {const tableNames = tableSuffixes.map((s) => this.getIndexName(s))const tablesToDrop: string[] = (await this.indexesList()).filter((t: string) => tableNames.indexOf(t) === -1)for (const t of tablesToDrop) {- this.logger.log(`${this.cleanIndexes.name} - drop table : ${t}`)+ this.logger.log({ tag: this.cleanIndexes.name, msg: `drop table : ${t}` })await this.dropIndex(t)}}diff --git a/backend/src/applications/files/modules/collabora-online/collabora-online-manager.service.ts b/backend/src/applications/files/modules/collabora-online/collabora-online-manager.service.tsindex dcdb7df2..93570406 100644--- a/backend/src/applications/files/modules/collabora-online/collabora-online-manager.service.ts+++ b/backend/src/applications/files/modules/collabora-online/collabora-online-manager.service.ts@@ -76,7 +76,7 @@ export class CollaboraOnlineManager {hasLock = this.filesLockManager.convertLockToFileLockProps(e.lock)mode = FILE_MODE.VIEW} else {- this.logger.error(`${this.getSettings.name} - ${e}`)+ this.logger.error({ tag: this.getSettings.name, msg: `${e}` })throw new HttpException('Unable to check file lock', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -124,11 +124,11 @@ export class CollaboraOnlineManager {if (!isNaN(contentLength) && contentLength !== 0) {const tmpFileSize = await fileSize(tmpFilePath)if (tmpFileSize !== contentLength) {- this.logger.error(`${this.saveDocument.name} - document size differs (${tmpFileSize} != ${contentLength})`)+ this.logger.error({ tag: this.saveDocument.name, msg: `document size differs (${tmpFileSize} != ${contentLength})` })throw new HttpException('Size Mismatch', HttpStatus.BAD_REQUEST)}} else if (contentLength === 0) {- this.logger.warn(`${this.saveDocument.name} - content length is 0 : ${req.space.url}`)+ this.logger.warn({ tag: this.saveDocument.name, msg: `content length is 0 : ${req.space.url}` })}// copy contents to avoid inode changes (dbFileHash in some cases)try {@@ -138,7 +138,7 @@ export class CollaboraOnlineManager {const fStats = await fs.stat(req.space.realPath)return { LastModifiedTime: fStats.mtime.toISOString() } satisfies CollaboraSaveDocumentDto} catch (e) {- this.logger.error(`${this.saveDocument.name} - unable to save document: ${e}`)+ this.logger.error({ tag: this.saveDocument.name, msg: `unable to save document: ${e}` })throw new HttpException('Unable to save document', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -199,7 +199,7 @@ export class CollaboraOnlineManager {break}default:- this.logger.warn(`${this.manageLock.name} - Unknown lock action: ${lockAction}`)+ this.logger.warn({ tag: this.manageLock.name, msg: `Unknown lock action: ${lockAction}` })throw new HttpException('Unknown lock action', HttpStatus.BAD_REQUEST)}}diff --git a/backend/src/applications/files/modules/only-office/only-office-manager.service.ts b/backend/src/applications/files/modules/only-office/only-office-manager.service.tsindex 49db9a3d..daa56226 100644--- a/backend/src/applications/files/modules/only-office/only-office-manager.service.ts+++ b/backend/src/applications/files/modules/only-office/only-office-manager.service.ts@@ -92,7 +92,7 @@ export class OnlyOfficeManager {hasLock = this.filesLockManager.convertLockToFileLockProps(e.lock)mode = FILE_MODE.VIEW} else {- this.logger.error(`${this.getSettings.name} - ${e}`)+ this.logger.error({ tag: this.getSettings.name, msg: `${e}` })throw new HttpException('Unable to check file lock', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -113,43 +113,43 @@ export class OnlyOfficeManager {case 1:// users connect / disconnectawait this.checkFileLock(user, space, callBackData)- this.logger.debug(`document is being edited : ${space.url}`)+ this.logger.debug({ tag: this.callBack.name, msg: `document is being edited : ${space.url}` })breakcase 2:// No active users on the documentawait this.checkFileLock(user, space, callBackData)if (callBackData.notmodified) {- this.logger.debug(`document was edited but closed with no changes : ${space.url}`)+ this.logger.debug({ tag: this.callBack.name, msg: `document was edited but closed with no changes : ${space.url}` })} else {- this.logger.debug(`document was edited and closed but not saved (let's do it) : ${space.url}`)+ this.logger.debug({ tag: this.callBack.name, msg: `document was edited and closed but not saved (let's do it) : ${space.url}` })await this.saveDocument(space, callBackData.url)}await this.removeFileLock(user.id, space)await this.removeDocumentKey(space)breakcase 3:- this.logger.error(`document cannot be saved, an error has occurred (try to save it) : ${space.url}`)+ this.logger.error({ tag: this.callBack.name, msg: `document cannot be saved, an error has occurred (try to save it) : ${space.url}` })await this.saveDocument(space, callBackData.url)breakcase 4:// No active users on the documentawait this.removeFileLock(user.id, space)await this.removeDocumentKey(space)- this.logger.debug(`document was closed with no changes : ${space.url}`)+ this.logger.debug({ tag: this.callBack.name, msg: `document was closed with no changes : ${space.url}` })breakcase 6:- this.logger.debug(`document is edited but save was requested : ${space.url}`)+ this.logger.debug({ tag: this.callBack.name, msg: `document is edited but save was requested : ${space.url}` })await this.saveDocument(space, callBackData.url)breakcase 7:- this.logger.error(`document cannot be force saved, an error has occurred (try to save it) : ${space.url}`)+ this.logger.error({ tag: this.callBack.name, msg: `document cannot be force saved, an error has occurred (try to save it) : ${space.url}` })await this.saveDocument(space, callBackData.url)breakdefault:- this.logger.error('unhandled case')+ this.logger.error({ tag: this.callBack.name, msg: 'unhandled case' })}} catch (e) {- this.logger.error(`${this.callBack.name} - ${e.message} : ${space.url}`)+ this.logger.error({ tag: this.callBack.name, msg: `${e.message} : ${space.url}` })return { error: e.message }}return { error: 0 }@@ -299,7 +299,7 @@ export class OnlyOfficeManager {if (!(await this.filesLockManager.isPathLocked(space.dbFile))) {const cacheKey = this.getCacheKey(space.dbFile)const r = await this.cache.del(cacheKey)- this.logger.debug(`${this.removeDocumentKey.name} - ${cacheKey} ${r ? '' : 'not'} removed`)+ this.logger.debug({ tag: this.removeDocumentKey.name, msg: `${cacheKey} ${r ? '' : 'not'} removed` })}}@@ -312,7 +312,7 @@ export class OnlyOfficeManager {}const docKey = genEtag(null, space.realPath, false)await this.cache.set(cacheKey, docKey, this.expiration)- this.logger.debug(`${this.getDocumentKey.name} - ${cacheKey} (${docKey}) created`)+ this.logger.debug({ tag: this.getDocumentKey.name, msg: `${cacheKey} (${docKey}) created` })return docKey}@@ -363,7 +363,7 @@ export class OnlyOfficeManager {throw new Error(`document size differs (${tmpFileSize} != ${contentLength})`)}} else if (contentLength === 0) {- this.logger.warn(`${this.saveDocument.name} - content length is 0 : ${space.url}`)+ this.logger.warn({ tag: this.saveDocument.name, msg: `content length is 0 : ${space.url}` })}// copy contents to avoid inode changes (`file.id` in some cases)try {@@ -401,7 +401,7 @@ export class OnlyOfficeManager {throw new Error(`convert failed with reason : ${ONLY_OFFICE_CONVERT_ERROR.get(result.error)}`)}if (result.endConvert) {- this.logger.log(`${this.convertDocument.name} - ${fileType} -> ${outputType} : ${spaceUrl}`)+ this.logger.log({ tag: this.convertDocument.name, msg: `${fileType} -> ${outputType} : ${spaceUrl}` })return result.fileUrl}}diff --git a/backend/src/applications/files/services/files-content-manager.service.ts b/backend/src/applications/files/services/files-content-manager.service.tsindex 79e66346..ba092a68 100644--- a/backend/src/applications/files/services/files-content-manager.service.ts+++ b/backend/src/applications/files/services/files-content-manager.service.ts@@ -37,7 +37,7 @@ export class FilesContentManager {try {await this.indexFiles(indexSuffix, paths)} catch (e) {- this.logger.error(`${this.parseAndIndexAllFiles.name} : ${e}`)+ this.logger.error({ tag: this.parseAndIndexAllFiles.name, msg: `${e}` })}indexSuffixes.push(indexSuffix)}@@ -69,7 +69,7 @@ export class FilesContentManager {if (rootFileContent !== null) {this.filesIndexer.insertRecord(indexName, rootFileContent).catch((e: Error) => {errorRecords++- this.logger.error(`${this.indexFiles.name} - ${indexSuffix} | ${rootFileContent.name} : ${e}`)+ this.logger.error({ tag: this.indexFiles.name, msg: `${indexSuffix} | ${rootFileContent.name} : ${e}` })})indexedRecords++}@@ -78,7 +78,7 @@ export class FilesContentManager {for await (const fileContent of this.parseFiles(p.realPath, context)) {this.filesIndexer.insertRecord(indexName, fileContent).catch((e: Error) => {errorRecords++- this.logger.error(`${this.indexFiles.name} - ${indexSuffix} | ${fileContent.name} : ${e}`)+ this.logger.error({ tag: this.indexFiles.name, msg: `${indexSuffix} | ${fileContent.name} : ${e}` })})indexedRecords++}@@ -88,22 +88,23 @@ export class FilesContentManager {// case when no datathis.filesIndexer.dropIndex(indexName)- .catch((e: Error) => this.logger.error(`${this.indexFiles.name} - ${indexSuffix} - unable to drop index : ${e}`))- this.logger.log(`${this.indexFiles.name} - ${indexSuffix} - no data, index not stored`)+ .catch((e: Error) => this.logger.error({ tag: this.indexFiles.name, msg: `${indexSuffix} - unable to drop index : ${e}` }))+ this.logger.log({ tag: this.indexFiles.name, msg: `${indexSuffix} - no data, index not stored` })} else {// clean up old recordsconst recordsToDelete: number[] = [...context.db.keys()].filter((key) => !context.fs.has(key))if (recordsToDelete.length > 0) {this.filesIndexer.deleteRecords(indexName, recordsToDelete)- .catch((e: Error) => this.logger.error(`${this.indexFiles.name} - ${indexSuffix} - unable to delete records : ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.indexFiles.name, msg: `${indexSuffix} - unable to delete records : ${e}` }))}if (indexedRecords === 0 && errorRecords === 0 && recordsToDelete.length === 0) {- this.logger.log(`${this.indexFiles.name} - ${indexSuffix} - no new data`)+ this.logger.log({ tag: this.indexFiles.name, msg: `${indexSuffix} - no new data` })} else {- this.logger.log(- `${this.indexFiles.name} - ${indexSuffix} - indexed: ${indexedRecords - errorRecords}, errors: ${errorRecords}, deleted: ${recordsToDelete.length}`- )+ this.logger.log({+ tag: this.indexFiles.name,+ msg: `${indexSuffix} - indexed: ${indexedRecords - errorRecords}, errors: ${errorRecords}, deleted: ${recordsToDelete.length}`+ })}}}@@ -122,7 +123,7 @@ export class FilesContentManager {}}} catch (e) {- this.logger.warn(`${this.parseFiles.name} - ${context.indexSuffix} - unable to parse: ${dir} - ${e}`)+ this.logger.warn({ tag: this.parseFiles.name, msg: `${context.indexSuffix} - unable to parse: ${dir} - ${e}` })}}@@ -139,7 +140,7 @@ export class FilesContentManager {try {stats = await fs.stat(realPath)} catch (e) {- this.logger.warn(`${this.analyzeFile.name} - unable to stats: ${realPath} - ${e}`)+ this.logger.warn({ tag: this.analyzeFile.name, msg: `unable to stats: ${realPath} - ${e}` })return null}if (stats.size === 0 || stats.size > this.maxDocumentSize) {@@ -184,7 +185,7 @@ export class FilesContentManager {)return content.length ? content : null} catch (e) {- this.logger.warn(`${this.parseContent.name} - unable to index: ${rPath} - ${e}`)+ this.logger.warn({ tag: this.parseContent.name, msg: `unable to index: ${rPath} - ${e}` })}return null}diff --git a/backend/src/applications/files/services/files-lock-manager.service.ts b/backend/src/applications/files/services/files-lock-manager.service.tsindex 30d0cdd8..a706dd93 100644--- a/backend/src/applications/files/services/files-lock-manager.service.ts+++ b/backend/src/applications/files/services/files-lock-manager.service.ts@@ -61,7 +61,7 @@ export class FilesLockManager {expiration: expiration,options: options}- this.logger.verbose(`${this.create.name} - ${key}`)+ this.logger.verbose({ tag: this.create.name, msg: `${key}` })await this.cache.set(key, lock, ttl)return [true, lock]}@@ -77,7 +77,7 @@ export class FilesLockManager {// Refresh if more than half of the TTL has passedconst mustRefresh = lock.expiration - currentTimeStamp() < ttl / 2if (mustRefresh) {- this.refreshLockTimeout(lock, ttl).catch((e: Error) => this.logger.error(`${this.createOrRefresh.name} - ${e}`))+ this.refreshLockTimeout(lock, ttl).catch((e: Error) => this.logger.error({ tag: this.createOrRefresh.name, msg: `${e}` }))}} else {throw new LockConflict(lock, 'Conflicting lock')@@ -94,7 +94,7 @@ export class FilesLockManager {}removeLock(key: string): Promise<boolean> {- this.logger.verbose(`${this.removeLock.name} - ${key}`)+ this.logger.verbose({ tag: this.removeLock.name, msg: `${key}` })return this.cache.del(key)}@@ -106,11 +106,11 @@ export class FilesLockManager {continue}const conflict = `cannot remove conflicting child lock : ${dbFile.path} (${user.login}) -> ${lock.dbFilePath} (${lock.owner.login})`- this.logger.debug(`${this.removeChildLocks.name} - ${conflict}`)+ this.logger.debug({ tag: this.removeChildLocks.name, msg: `${conflict}` })throw new LockConflict(lock, conflict)}for (const key of ownedLockKeys) {- this.logger.verbose(`${this.removeChildLocks.name} - child locks: ${key}`)+ this.logger.verbose({ tag: this.removeChildLocks.name, msg: `child locks: ${key}` })await this.removeLock(key)}}@@ -144,7 +144,7 @@ export class FilesLockManager {async refreshLockTimeout(lock: FileLock, ttl: number) {lock.expiration = currentTimeStamp() + ttl- this.cache.set(lock.key, lock, ttl).catch((e: Error) => this.logger.error(`${this.refreshLockTimeout.name} - ${e}`))+ this.cache.set(lock.key, lock, ttl).catch((e: Error) => this.logger.error({ tag: this.refreshLockTimeout.name, msg: `${e}` }))}async getLockByToken(token: string): Promise<FileLock> {@@ -188,7 +188,7 @@ export class FilesLockManager {continue}const conflict = `conflicting parent lock : ${dbFile.path} -> ${l.dbFilePath} (${l.owner.login})`- this.logger.debug(`${this.checkConflicts.name} - ${conflict}`)+ this.logger.debug({ tag: this.checkConflicts.name, msg: `${conflict}` })throw new LockConflict(l, conflict)}if (depth === DEPTH.INFINITY) {@@ -198,7 +198,7 @@ export class FilesLockManager {continue}const conflict = `conflicting child lock : ${dbFile.path} -> ${l.dbFilePath} (${l.owner.login})`- this.logger.debug(`${this.checkConflicts.name} - ${conflict}`)+ this.logger.debug({ tag: this.checkConflicts.name, msg: `${conflict}` })throw new LockConflict(l, conflict)}}@@ -207,11 +207,11 @@ export class FilesLockManager {async *searchChildLocks(dbFile: FileDBProps) {const props = this.genSuffixKey(dbFile, { ignorePath: true })const path = dbFile.path === '.' ? '*' : `${dbFile.path}/*`- this.logger.verbose(`${this.searchChildLocks.name} - ${path} (${props})`)+ this.logger.verbose({ tag: this.searchChildLocks.name, msg: `${path} (${props})` })const keys = await this.searchKeysByPath(path, props)if (keys.length) {for (const l of (await this.cache.mget(keys)).filter(Boolean) as FileLock[]) {- this.logger.verbose(`-> ${l.dbFilePath} (owner: ${l.owner.login})`)+ this.logger.verbose({ tag: this.searchChildLocks.name, msg: `-> ${l.dbFilePath} (owner: ${l.owner.login})` })yield l}}@@ -235,7 +235,7 @@ export class FilesLockManager {const props = this.genSuffixKey(dbFile, { ignorePath: true })let path = dbFile.pathconst parentPath = dirName(path)- this.logger.verbose(`${this.searchParentLocks.name} - (including root : ${options.includeRoot}) : ${path} (${props})`)+ this.logger.verbose({ tag: this.searchParentLocks.name, msg: `(including root : ${options.includeRoot}) : ${path} (${props})` })if (!options.includeRoot) {path = dirName(path)}@@ -245,7 +245,7 @@ export class FilesLockManager {const keys = await this.searchKeysByPath(path, props, depth)if (keys.length) {for (const l of (await this.cache.mget(keys)).filter(Boolean) as FileLock[]) {- this.logger.verbose(`-> ${l.dbFilePath}`)+ this.logger.verbose({ tag: this.searchParentLocks.name, msg: `-> ${l.dbFilePath}` })yield l}}@@ -258,7 +258,7 @@ export class FilesLockManager {if (!keys.length) {return null} else if (keys.length > 1) {- this.logger.warn(`Several keys found for token : ${token} => ${JSON.stringify(keys)}`)+ this.logger.warn({ tag: this.searchKeyByToken.name, msg: `Several keys found for token : ${token} => ${JSON.stringify(keys)}` })}return keys[0]}diff --git a/backend/src/applications/files/services/files-manager.service.ts b/backend/src/applications/files/services/files-manager.service.tsindex 883c2d11..2c609715 100644--- a/backend/src/applications/files/services/files-manager.service.ts+++ b/backend/src/applications/files/services/files-manager.service.ts@@ -161,7 +161,7 @@ export class FilesManager {} catch (e) {// cleanup tmp fileawait removeFiles(options.tmpPath)- this.logger.error(`${this.saveStream.name} - unable to move ${options.tmpPath} -> ${space.realPath} : ${e}`)+ this.logger.error({ tag: this.saveStream.name, msg: `unable to move ${options.tmpPath} -> ${space.realPath} : ${e}` })throw new FileError(HttpStatus.INTERNAL_SERVER_ERROR, 'Unable to move tmp file to dst file')}}@@ -174,7 +174,7 @@ export class FilesManager {try {await this.filesLockManager.removeLock(fileLock.key)} catch (e) {- this.logger.warn(`Failed to remove lock ${fileLock.key}: ${e}`)+ this.logger.warn({ tag: this.saveStream.name, msg: `Failed to remove lock ${fileLock.key}: ${e}` })}}}@@ -311,15 +311,18 @@ export class FilesManager {): Promise<void> {// checksif (!canAccessToSpace(user, dstSpace)) {- this.logger.warn(`${this.copyMove.name} - is not allowed to access to this space repository : ${dstSpace.repository}`)+ this.logger.warn({ tag: this.copyMove.name, msg: `is not allowed to access to this space repository : ${dstSpace.repository}` })throw new FileError(HttpStatus.FORBIDDEN, 'You are not allowed to access to this repository')}if (!haveSpaceEnvPermissions(dstSpace, SPACE_OPERATION.ADD)) {- this.logger.warn(`${this.copyMove.name} - is not allowed to copy/move on this space : *${dstSpace.alias}* (${dstSpace.id}) : ${dstSpace.url}`)+ this.logger.warn({+ tag: this.copyMove.name,+ msg: `is not allowed to copy/move on this space : *${dstSpace.alias}* (${dstSpace.id}) : ${dstSpace.url}`+ })throw new FileError(HttpStatus.FORBIDDEN, 'You are not allowed to copy/move on the destination')}if (dstSpace.quotaIsExceeded) {- this.logger.warn(`${this.copyMove.name} - quota is exceeded for *${dstSpace.alias}* (${dstSpace.id})`)+ this.logger.warn({ tag: this.copyMove.name, msg: `quota is exceeded for *${dstSpace.alias}* (${dstSpace.id})` })throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, 'Quota is exceeded')}if (!(await isPathExists(srcSpace.realPath))) {@@ -330,7 +333,7 @@ export class FilesManager {try {await makeDir(dirName(dstSpace.realPath), true)} catch (e) {- this.logger.error(`${this.copyMove.name} - Cannot create parent directory for destination ${dstSpace.realPath} : ${e}`)+ this.logger.error({ tag: this.copyMove.name, msg: `Cannot create parent directory for destination ${dstSpace.realPath} : ${e}` })throw new FileError(HttpStatus.INTERNAL_SERVER_ERROR, 'Cannot create parent directory for destination')}} else {@@ -370,7 +373,7 @@ export class FilesManager {if (!isMove || (isMove && srcSpace.id !== dstSpace.id)) {const size = isDir ? (await dirSize(srcSpace.realPath))[0] : await fileSize(srcSpace.realPath)if (dstSpace.willExceedQuota(size)) {- this.logger.warn(`${this.copyMove.name} - storage quota will be exceeded for *${dstSpace.alias}* (${dstSpace.id})`)+ this.logger.warn({ tag: this.copyMove.name, msg: `storage quota will be exceeded for *${dstSpace.alias}* (${dstSpace.id})` })throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, 'Storage quota will be exceeded')}}@@ -449,24 +452,27 @@ export class FilesManager {await moveFiles(space.realPath, trashFile, true)} else {// unsupported case: delete the file (this shouldn't happen)- this.logger.error(`Unable to find trash path for space - *${space.alias}* (${space.id}) : delete permanently : ${space.realPath}`)+ this.logger.error({+ tag: this.delete.name,+ msg: `Unable to find trash path for space - *${space.alias}* (${space.id}) : delete permanently : ${space.realPath}`+ })forceDeleteInDB = trueawait removeFiles(space.realPath)}}// remove locks, these locks have already been checked in the `checkConflicts` functionif (isDir) {- this.filesLockManager.removeChildLocks(user, space.dbFile).catch((e: Error) => this.logger.error(`${this.delete.name} - ${e}`))+ this.filesLockManager.removeChildLocks(user, space.dbFile).catch((e: Error) => this.logger.error({ tag: this.delete.name, msg: `${e}` }))}for (const lock of await this.filesLockManager.getLocksByPath(space.dbFile)) {- this.filesLockManager.removeLock(lock.key).catch((e: Error) => this.logger.error(`${this.delete.name} - ${e}`))+ this.filesLockManager.removeLock(lock.key).catch((e: Error) => this.logger.error({ tag: this.delete.name, msg: `${e}` }))}// delete or move to trash the files in dbreturn this.filesQueries.deleteFiles(space.dbFile, isDir, forceDeleteInDB)}async downloadFromUrl(user: UserModel, space: SpaceEnv, url: string): Promise<void> {- this.logger.log(`${this.downloadFromUrl.name} : ${url}`)+ this.logger.log({ tag: this.downloadFromUrl.name, msg: `${url}` })// create lockconst rPath = await uniqueFilePathFromDir(space.realPath)const dbFile = space.dbFile@@ -484,7 +490,7 @@ export class FilesManager {} catch (e) {// release lockawait this.filesLockManager.removeLock(fileLock.key)- this.logger.error(`${this.downloadFromUrl.name} - ${url} : ${e}`)+ this.logger.error({ tag: this.downloadFromUrl.name, msg: `${url} : ${e}` })throw new FileError(HttpStatus.BAD_REQUEST, 'Unable to download file')}@@ -501,7 +507,7 @@ export class FilesManager {space.task.props.totalSize = parseInt(headRes.headers['content-length'], 10) || null}} catch (e) {- this.logger.debug(`${this.downloadFromUrl.name} - content-length : ${e}`)+ this.logger.debug({ tag: this.downloadFromUrl.name, msg: `content-length : ${e}` })}FileTaskEvent.emit('startWatch', space, FILE_OPERATION.DOWNLOAD, rPath)}@@ -619,7 +625,7 @@ export class FilesManager {try {return generateThumbnail(space.realPath, size)} catch (e) {- this.logger.warn(e)+ this.logger.warn({ tag: this.generateThumbnail.name, msg: e })throw new FileError(HttpStatus.BAD_REQUEST, 'File is not an image')}}@@ -627,7 +633,7 @@ export class FilesManager {async lock(user: UserModel, space: SpaceEnv): Promise<FileLockProps> {const rExists = await isPathExists(space.realPath)if (!rExists) {- this.logger.warn('Lock refresh must specify an existing resource')+ this.logger.warn({ tag: this.lock.name, msg: 'Lock refresh must specify an existing resource' })throw new FileError(HttpStatus.BAD_REQUEST, 'Lock refresh must specify an existing resource')}const [_created, lock] = await this.filesLockManager.createOrRefresh(user, space.dbFile, SERVER_NAME, DEPTH.RESOURCE, CACHE_LOCK_FILE_TTL)@@ -636,12 +642,12 @@ export class FilesManager {async unlock(user: UserModel, space: SpaceEnv, forceAsFileOwner = false): Promise<void> {if (!(await isPathExists(space.realPath))) {- this.logger.warn(`Unable to unlock: ${space.url} - resource does not exist`)+ this.logger.warn({ tag: this.unlock.name, msg: `Unable to unlock: ${space.url} - resource does not exist` })throw new FileError(HttpStatus.BAD_REQUEST, 'Unlock must specify an existing resource')}const fileLocks = await this.filesLockManager.getLocksByPath(space.dbFile)if (fileLocks.length === 0) {- this.logger.warn(`Unable to find lock: ${space.url} - resource does not exist`)+ this.logger.warn({ tag: this.unlock.name, msg: `Unable to find lock: ${space.url} - resource does not exist` })return}for (const lock of fileLocks) {@@ -657,7 +663,7 @@ export class FilesManager {async unlockRequest(user: UserModel, space: SpaceEnv): Promise<void> {const fileLocks = await this.filesLockManager.getLocksByPath(space.dbFile)if (fileLocks.length === 0) {- this.logger.warn(`Unable to find lock: ${space.url} - resource does not exist`)+ this.logger.warn({ tag: this.unlockRequest.name, msg: `Unable to find lock: ${space.url} - resource does not exist` })throw new FileError(HttpStatus.NOT_FOUND, 'Lock not found')}for (const lock of fileLocks) {@@ -673,7 +679,7 @@ export class FilesManager {author: user,currentUrl: this.contextManager.headerOriginUrl()})- .catch((e: Error) => this.logger.error(`${this.unlockRequest.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.unlockRequest.name, msg: `${e}` }))}}}diff --git a/backend/src/applications/files/services/files-methods.service.ts b/backend/src/applications/files/services/files-methods.service.tsindex 2d33ee18..f534a6b0 100644--- a/backend/src/applications/files/services/files-methods.service.ts+++ b/backend/src/applications/files/services/files-methods.service.ts@@ -200,7 +200,7 @@ export class FilesMethods {}private handleError(space: SpaceEnv, action: string, e: any, dstSpace?: SpaceEnv) {- this.logger.error(`unable to ${action} ${space.url}${dstSpace?.url ? ` -> ${dstSpace.url}` : ''} : ${e}`)+ this.logger.error({ tag: this.handleError.name, msg: `unable to ${action} ${space.url}${dstSpace?.url ? ` -> ${dstSpace.url}` : ''} : ${e}` })// Remove the last part to avoid exposing the pathconst errorMsg = e.message.split(',')[0]if (e instanceof LockConflict) {diff --git a/backend/src/applications/files/services/files-parser.service.ts b/backend/src/applications/files/services/files-parser.service.tsindex 8afab095..e0c5cd82 100644--- a/backend/src/applications/files/services/files-parser.service.ts+++ b/backend/src/applications/files/services/files-parser.service.ts@@ -39,7 +39,7 @@ export class FilesParser {.where(and(...[eq(users.storageIndexing, true), lte(users.role, USER_ROLE.USER), ...(userId ? [eq(users.id, userId)] : [])]))) {const userFilesPath = UserModel.getFilesPath(user.login)if (!(await isPathExists(userFilesPath))) {- this.logger.warn(`${this.userPaths.name} - user path does not exist : ${userFilesPath}`)+ this.logger.warn({ tag: this.userPaths.name, msg: `user path does not exist : ${userFilesPath}` })continue}yield [user.id, 'user', [{ realPath: userFilesPath, pathPrefix: `${SPACE_REPOSITORY.FILES}/${SPACE_ALIAS.PERSONAL}`, isDir: true }]]@@ -69,7 +69,7 @@ export class FilesParser {.groupBy(spaces.id)) {const spaceFilesPath = SpaceModel.getFilesPath(space.alias)if (!(await isPathExists(spaceFilesPath))) {- this.logger.warn(`${this.spacePaths.name} - space path does not exist : ${spaceFilesPath}`)+ this.logger.warn({ tag: this.spacePaths.name, msg: `space path does not exist : ${spaceFilesPath}` })continue}const spacePath = [{ realPath: spaceFilesPath, pathPrefix: `${SPACE_REPOSITORY.FILES}/${space.alias}`, isDir: true }]@@ -126,7 +126,7 @@ export class FilesParser {continue}if (!(await isPathExists(shareFilesPath))) {- this.logger.warn(`${this.sharePaths.name} - share path does not exist : ${shareFilesPath}`)+ this.logger.warn({ tag: this.sharePaths.name, msg: `share path does not exist : ${shareFilesPath}` })continue}yield [share.id, 'share', [{ realPath: shareFilesPath, pathPrefix: `${SPACE_REPOSITORY.SHARES}/${share.alias}`, isDir: share.isDir }]]diff --git a/backend/src/applications/files/services/files-queries.service.ts b/backend/src/applications/files/services/files-queries.service.tsindex 9eb35bde..2ba73891 100644--- a/backend/src/applications/files/services/files-queries.service.ts+++ b/backend/src/applications/files/services/files-queries.service.ts@@ -107,7 +107,7 @@ export class FilesQueries {if (searchFileInDB?.id === file.id) {return file.id} else {- this.logger.warn(`${this.getOrCreateUserFile.name} - file mismatch : ${JSON.stringify(searchFileInDB)} !== ${JSON.stringify(file)}`)+ this.logger.warn({ tag: this.getOrCreateUserFile.name, msg: `file mismatch : ${JSON.stringify(searchFileInDB)} !== ${JSON.stringify(file)}` })}}return dbGetInsertedId(await this.db.insert(files).values({ ...file, id: undefined, ownerId: userId } as File))@@ -129,7 +129,10 @@ export class FilesQueries {if (searchFileInDB?.id === fileId) {return fileId} else {- this.logger.warn(`${this.getOrCreateSpaceFile.name} - file mismatch : ${JSON.stringify(dbFile)} -> ${fileId} !== ${searchFileInDB?.id}`)+ this.logger.warn({+ tag: this.getOrCreateSpaceFile.name,+ msg: `file mismatch : ${JSON.stringify(dbFile)} -> ${fileId} !== ${searchFileInDB?.id}`+ })}}// order is important, path is replaced by the FileProps.path@@ -155,7 +158,7 @@ export class FilesQueries {try {dbCheckAffectedRows(await this.db.update(files).set(file).where(eq(files.id, id)), 1)} catch (e) {- this.logger.error(`${this.updateFile.name} - file (${id}) properties was not updated : ${e}`)+ this.logger.error({ tag: this.updateFile.name, msg: `file (${id}) properties was not updated : ${e}` })}}@@ -259,7 +262,7 @@ export class FilesQueries {dbFile.mtime !== fsFile.mtime ||dbFile.mime !== fsFile.mime) {- this.logger.verbose(`${this.compareAndUpdateFileProps.name} - ${dbFile.path} (${dbFile.id})`)+ this.logger.verbose({ tag: this.compareAndUpdateFileProps.name, msg: `${dbFile.path} (${dbFile.id})` })await this.updateFile(dbFile.id, {isDir: fsFile.isDir,size: fsFile.size,@@ -309,7 +312,7 @@ export class FilesQueries {try {await this.db.insert(filesRecents).values(add as FileRecent[])} catch (e) {- this.logger.error(`${this.updateRecents.name} - ${e}`)+ this.logger.error({ tag: this.updateRecents.name, msg: `${e}` })}}// update@@ -323,7 +326,7 @@ export class FilesQueries {.where(and(...where, eq(filesRecents.id, f.id))).limit(1)} catch (e) {- this.logger.error(`${this.updateRecents.name} - ${e}`)+ this.logger.error({ tag: this.updateRecents.name, msg: `${e}` })}}}@@ -332,7 +335,7 @@ export class FilesQueries {try {await this.db.delete(filesRecents).where(and(...where, inArray(filesRecents.id, remove)))} catch (e) {- this.logger.error(`${this.updateRecents.name} - ${e}`)+ this.logger.error({ tag: this.updateRecents.name, msg: `${e}` })}}}diff --git a/backend/src/applications/files/services/files-scheduler.service.ts b/backend/src/applications/files/services/files-scheduler.service.tsindex 8153e1c1..6ab0b556 100644--- a/backend/src/applications/files/services/files-scheduler.service.ts+++ b/backend/src/applications/files/services/files-scheduler.service.ts@@ -50,7 +50,7 @@ export class FilesScheduler {}async cleanupInterruptedTasks(): Promise<void> {- this.logger.log(`${this.cleanupInterruptedTasks.name} - START`)+ this.logger.log({ tag: this.cleanupInterruptedTasks.name, msg: `START` })try {let nb = 0const keys = await this.cache.keys(`${CACHE_TASK_PREFIX}-*`)@@ -60,18 +60,18 @@ export class FilesScheduler {task.status = FileTaskStatus.ERRORtask.result = 'Interrupted'nb++- this.cache.set(key, task).catch((e: Error) => this.logger.error(`${this.cleanupInterruptedTasks.name} - ${e}`))+ this.cache.set(key, task).catch((e: Error) => this.logger.error({ tag: this.cleanupInterruptedTasks.name, msg: `${e}` }))}}- this.logger.log(`${this.cleanupInterruptedTasks.name} - ${nb} tasks cleaned : END`)+ this.logger.log({ tag: this.cleanupInterruptedTasks.name, msg: `${nb} tasks cleaned : END` })} catch (e) {- this.logger.error(`${this.cleanupInterruptedTasks.name} - ${e}`)+ this.logger.error({ tag: this.cleanupInterruptedTasks.name, msg: `${e}` })}}@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)async cleanupUserTaskFiles(): Promise<void> {- this.logger.log(`${this.cleanupUserTaskFiles.name} - START`)+ this.logger.log({ tag: this.cleanupUserTaskFiles.name, msg: `START` })try {for (const user of await this.db.select({@@ -92,22 +92,22 @@ export class FilesScheduler {.map((task: FileTask) => task.name)for (const f of (await fs.readdir(userTasksPath)).filter((f: string) => excludeFiles.indexOf(f) === -1)) {try {- removeFiles(path.join(userTasksPath, f)).catch((e: Error) => this.logger.error(`${this.cleanupUserTaskFiles.name} - ${e}`))+ removeFiles(path.join(userTasksPath, f)).catch((e: Error) => this.logger.error({ tag: this.cleanupUserTaskFiles.name, msg: `${e}` }))} catch (e) {- this.logger.error(`${this.cleanupUserTaskFiles.name} - unable to remove ${path.join(userTasksPath, f)} : ${e}`)+ this.logger.error({ tag: this.cleanupUserTaskFiles.name, msg: `unable to remove ${path.join(userTasksPath, f)} : ${e}` })}}}}} catch (e) {- this.logger.error(`${this.cleanupUserTaskFiles.name} - ${e}`)+ this.logger.error({ tag: this.cleanupUserTaskFiles.name, msg: `${e}` })}- this.logger.log(`${this.cleanupUserTaskFiles.name} - END`)+ this.logger.log({ tag: this.cleanupUserTaskFiles.name, msg: `END` })}@Cron(CronExpression.EVERY_8_HOURS)async clearRecentFiles(): Promise<void> {- this.logger.log(`${this.clearRecentFiles.name} - START`)+ this.logger.log({ tag: this.clearRecentFiles.name, msg: `START` })const keepNumber = 100let nbCleared = 0try {@@ -126,29 +126,29 @@ export class FilesScheduler {nbCleared += r.affectedRows}} catch (e) {- this.logger.error(`${this.clearRecentFiles.name} - ${e}`)+ this.logger.error({ tag: this.clearRecentFiles.name, msg: `${e}` })}- this.logger.log(`${this.clearRecentFiles.name} - ${nbCleared} records cleared - END`)+ this.logger.log({ tag: this.clearRecentFiles.name, msg: `${nbCleared} records cleared - END` })}@Cron(CronExpression.EVERY_4_HOURS)async indexContentFiles(): Promise<void> {// Conditional loading of file content indexingif (!configuration.applications.files.contentIndexing) return- this.logger.log(`${this.indexContentFiles.name} - START`)+ this.logger.log({ tag: this.indexContentFiles.name, msg: `START` })await this.filesContentManager.parseAndIndexAllFiles()- this.logger.log(`${this.indexContentFiles.name} - END`)+ this.logger.log({ tag: this.indexContentFiles.name, msg: `END` })}@Cron(CronExpression.EVERY_DAY_AT_4AM)async deleteOrphanFiles() {- this.logger.log(`${this.deleteOrphanFiles.name} - START`)+ this.logger.log({ tag: this.deleteOrphanFiles.name, msg: `START` })const selects: any[] = []for (const table of getTablesWithFileIdColumn()) {selects.push(this.db.selectDistinct({ id: table.fileId }).from(table).where(isNotNull(table.fileId)))}if (selects.length === 0) {- this.logger.warn(`${this.deleteOrphanFiles.name} - no tables with fileId column`)+ this.logger.warn({ tag: this.deleteOrphanFiles.name, msg: `no tables with fileId column` })return}const unionSub = (selects.length === 1 ? selects[0] : unionAll(...(selects as [any, any, ...any[]]))).as('u')@@ -169,11 +169,11 @@ export class FilesScheduler {try {await this.db.transaction(async (tx) => {const [r] = await tx.execute(deleteQuery)- this.logger.log(`${this.deleteOrphanFiles.name} - files: ${r.affectedRows}`)+ this.logger.log({ tag: this.deleteOrphanFiles.name, msg: `files: ${r.affectedRows}` })})} catch (e) {- this.logger.log(`${this.deleteOrphanFiles.name} - ${e}`)+ this.logger.log({ tag: this.deleteOrphanFiles.name, msg: `${e}` })}- this.logger.log(`${this.deleteOrphanFiles.name} - END`)+ this.logger.log({ tag: this.deleteOrphanFiles.name, msg: `END` })}}diff --git a/backend/src/applications/files/services/files-search-manager.service.ts b/backend/src/applications/files/services/files-search-manager.service.tsindex e6ac10b0..c4fd72b3 100644--- a/backend/src/applications/files/services/files-search-manager.service.ts+++ b/backend/src/applications/files/services/files-search-manager.service.ts@@ -49,7 +49,7 @@ export class FilesSearchManager {try {return await this.filesIndexer.searchRecords(indexNames, search, limit)} catch (e) {- this.logger.error(`${this.searchFullText.name} - ${JSON.stringify(indexNames)} - ${search} : ${e}`)+ this.logger.error({ tag: this.searchFullText.name, msg: `${JSON.stringify(indexNames)} - ${search} : ${e}` })let msg: stringif (/Invalid regular expression/.test(e.message)) {msg = 'SyntaxError (check special characters)'@@ -97,7 +97,7 @@ export class FilesSearchManager {}}} catch (e) {- this.logger.warn(`${this.parseFileNames.name} - unable to parse: ${dir} (${e})`)+ this.logger.warn({ tag: this.parseFileNames.name, msg: `unable to parse: ${dir} (${e})` })}}diff --git a/backend/src/applications/files/services/files-tasks-manager.service.ts b/backend/src/applications/files/services/files-tasks-manager.service.tsindex 6c5b9d80..bfb2d928 100644--- a/backend/src/applications/files/services/files-tasks-manager.service.ts+++ b/backend/src/applications/files/services/files-tasks-manager.service.ts@@ -45,12 +45,12 @@ export class FilesTasksManager {space.task = { cacheKey: cacheKey, props: {} }this.filesMethods[method](user, space, dto).then((data: any) => {- this.logger.debug(`${this.createTask.name} - ${newTask.name} : ${method} done`)- this.setTaskDone(cacheKey, FileTaskStatus.SUCCESS, data).catch((e: Error) => this.logger.error(`${this.createTask.name} - ${e}`))+ this.logger.debug({ tag: this.createTask.name, msg: `${newTask.name} : ${method} done` })+ this.setTaskDone(cacheKey, FileTaskStatus.SUCCESS, data).catch((e: Error) => this.logger.error({ tag: this.createTask.name, msg: `${e}` }))}).catch((e: HttpException | any) => {- this.logger.error(`${this.createTask.name} - ${newTask.name} : ${method} : ${e}`)- this.setTaskDone(cacheKey, FileTaskStatus.ERROR, e.message).catch((e: Error) => this.logger.error(`${this.createTask.name} - ${e}`))+ this.logger.error({ tag: this.createTask.name, msg: `${newTask.name} : ${method} : ${e}` })+ this.setTaskDone(cacheKey, FileTaskStatus.ERROR, e.message).catch((e: Error) => this.logger.error({ tag: this.createTask.name, msg: `${e}` }))})return newTask}@@ -82,12 +82,12 @@ export class FilesTasksManager {if (task.props.compressInDirectory === false) {// delete task fileconst rPath = path.join(user.tasksPath, task.name)- removeFiles(rPath).catch((e: Error) => this.logger.error(`${this.deleteTasks.name} - ${e}`))+ removeFiles(rPath).catch((e: Error) => this.logger.error({ tag: this.deleteTasks.name, msg: `${e}` }))}// clear watcher- this.stopWatch(key).catch((e: Error) => this.logger.error(`${this.deleteTasks.name} - ${e}`))+ this.stopWatch(key).catch((e: Error) => this.logger.error({ tag: this.deleteTasks.name, msg: `${e}` }))// remove from cache- this.cache.del(key).catch((e: Error) => this.logger.error(`${this.deleteTasks.name} - ${e}`))+ this.cache.del(key).catch((e: Error) => this.logger.error({ tag: this.deleteTasks.name, msg: `${e}` }))}}@@ -113,7 +113,7 @@ export class FilesTasksManager {try {await this.cache.set(cacheKey, task, CACHE_TASK_TTL)} catch (e) {- this.logger.error(`${this.storeTask.name} - ${e}`)+ this.logger.error({ tag: this.storeTask.name, msg: `${e}` })}}@@ -147,11 +147,11 @@ export class FilesTasksManager {private async startWatch(space: SpaceEnv, taskType: FILE_OPERATION, rPath: string, taskPath?: string): Promise<void> {if (!space.task?.cacheKey || space.task.cacheKey in this.tasksWatcher) return- this.logger.verbose(`${this.startWatch.name} - ${space.task.cacheKey}`)+ this.logger.verbose({ tag: this.startWatch.name, msg: `${space.task.cacheKey}` })this.updateTask(space.task.cacheKey, space.task?.props, {name: fileName(rPath),path: taskPath- }).catch((e: Error) => this.logger.error(`${this.startWatch.name} - ${e}`))+ }).catch((e: Error) => this.logger.error({ tag: this.startWatch.name, msg: `${e}` }))switch (taskType) {case FILE_OPERATION.COMPRESS:this.tasksWatcher[space.task.cacheKey] = setInterval(async () => this.updateCompressTask(space, rPath), this.watchInterval)@@ -167,7 +167,7 @@ export class FilesTasksManager {this.tasksWatcher[space.task.cacheKey] = setInterval(async () => this.updateCopyMoveTask(space, rPath), this.watchInterval)returndefault:- this.logger.warn(`${this.startWatch.name} - unknown task type ${taskType}`)+ this.logger.warn({ tag: this.startWatch.name, msg: `unknown task type ${taskType}` })return}}@@ -182,9 +182,11 @@ export class FilesTasksManager {private async updateCompressTask(space: SpaceEnv, rPath: string): Promise<void> {try {space.task.props.size = await fileSize(rPath)- await this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) => this.logger.error(`${this.updateCompressTask.name} - ${e}`))+ await this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) =>+ this.logger.error({ tag: this.updateCompressTask.name, msg: `${e}` })+ )} catch (e) {- this.logger.error(`${this.updateCompressTask.name} - ${e}`)+ this.logger.error({ tag: this.updateCompressTask.name, msg: `${e}` })await this.stopWatch(space.task.cacheKey)}}@@ -192,9 +194,11 @@ export class FilesTasksManager {private async updateDecompressTask(space: SpaceEnv, rPath: string): Promise<void> {try {space.task.props = await countDirEntries(rPath)- this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) => this.logger.error(`${this.updateDecompressTask.name} - ${e}`))+ this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) =>+ this.logger.error({ tag: this.updateDecompressTask.name, msg: `${e}` })+ )} catch (e) {- this.logger.error(`${this.updateDecompressTask.name} - ${e}`)+ this.logger.error({ tag: this.updateDecompressTask.name, msg: `${e}` })await this.stopWatch(space.task.cacheKey)}}@@ -202,9 +206,11 @@ export class FilesTasksManager {private async updateDownloadTask(space: SpaceEnv, rPath: string): Promise<void> {try {await this.calcSizeAndProgressTask(space, rPath)- this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) => this.logger.error(`${this.updateDownloadTask.name} - ${e}`))+ this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) =>+ this.logger.error({ tag: this.updateDownloadTask.name, msg: `${e}` })+ )} catch (e) {- this.logger.error(`${this.updateDownloadTask.name} - ${e}`)+ this.logger.error({ tag: this.updateDownloadTask.name, msg: `${e}` })await this.stopWatch(space.task.cacheKey)}}@@ -216,9 +222,11 @@ export class FilesTasksManager {} else {await this.calcSizeAndProgressTask(space, rPath)}- this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) => this.logger.error(`${this.updateCopyMoveTask.name} - ${e}`))+ this.updateTask(space.task.cacheKey, space.task.props).catch((e: Error) =>+ this.logger.error({ tag: this.updateCopyMoveTask.name, msg: `${e}` })+ )} catch (e) {- this.logger.error(`${this.updateCopyMoveTask.name} - ${e}`)+ this.logger.error({ tag: this.updateCopyMoveTask.name, msg: `${e}` })await this.stopWatch(space.task.cacheKey)}}diff --git a/backend/src/applications/links/services/links-manager.service.ts b/backend/src/applications/links/services/links-manager.service.tsindex e9fe29f9..c33e34fb 100644--- a/backend/src/applications/links/services/links-manager.service.ts+++ b/backend/src/applications/links/services/links-manager.service.ts@@ -33,7 +33,7 @@ export class LinksManager {async linkValidation(identity: JwtIdentityPayload, uuid: string): Promise<{ ok: boolean; error: string | true; link: SpaceLink }> {const [_link, check, ok] = await this.linkEnv(identity, uuid)if (!ok) {- this.logger.warn(`${this.linkValidation.name} - ${uuid} : ${check}`)+ this.logger.warn({ tag: this.linkValidation.name, msg: `${uuid} : ${check}` })}const spaceLink: SpaceLink = ok ? await this.linksQueries.spaceLink(uuid) : nullif (ok) {@@ -58,15 +58,15 @@ export class LinksManager {): Promise<LoginResponseDto | Omit<LoginResponseDto, 'token'>> {const [link, check, ok] = await this.linkEnv(identity, uuid)if (!ok) {- this.logger.warn(`${this.linkAccess.name} - *${link.user.login}* (${link.user.id}) : ${check}`)+ this.logger.warn({ tag: this.linkAccess.name, msg: `*${link.user.login}* (${link.user.id}) : ${check}` })throw new HttpException(check as string, HttpStatus.BAD_REQUEST)}const user = new UserModel(link.user)if (link.user.id !== identity.id) {// Authenticate user to allow access to the directory- this.logger.log(`${this.linkAccess.name} - *${user.login}* (${user.id}) is logged`)+ this.logger.log({ tag: this.linkAccess.name, msg: `*${user.login}* (${user.id}) is logged` })this.incrementLinkNbAccess(link)- this.usersManager.updateAccesses(user, req.ip, true).catch((e: Error) => this.logger.error(`${this.linkAccess.name} - ${e}`))+ this.usersManager.updateAccesses(user, req.ip, true).catch((e: Error) => this.logger.error({ tag: this.linkAccess.name, msg: `${e}` }))return this.authManager.setCookies(user, res)}// Already authenticated@@ -76,17 +76,17 @@ export class LinksManager {async linkDownload(identity: JwtIdentityPayload, uuid: string, req: FastifyRequest, res: FastifyReply): Promise<StreamableFile> {const [link, check, ok] = await this.linkEnv(identity, uuid)if (!ok) {- this.logger.warn(`${this.linkDownload.name} - *${link.user.login}* (${link.user.id}) : ${check}`)+ this.logger.warn({ tag: this.linkDownload.name, msg: `*${link.user.login}* (${link.user.id}) : ${check}` })throw new HttpException(check as string, HttpStatus.BAD_REQUEST)}const spaceLink: SpaceLink = await this.linksQueries.spaceLink(uuid)if (spaceLink.space || spaceLink.share?.isDir) {- this.logger.error(`${this.linkDownload.name} - the provided link does not reference a downloadable file`)+ this.logger.error({ tag: this.linkDownload.name, msg: `the provided link does not reference a downloadable file` })throw new HttpException('This link does not allow file download', HttpStatus.BAD_REQUEST)}const user = new UserModel(link.user)// Download the file (authentication has been verified before)- this.logger.log(`${this.linkDownload.name} - *${user.login}* (${user.id}) downloading ${spaceLink.share.name}`)+ this.logger.log({ tag: this.linkDownload.name, msg: `*${user.login}* (${user.id}) downloading ${spaceLink.share.name}` })this.incrementLinkNbAccess(link)const spaceEnv: SpaceEnv = await this.spaceEnvFromLink(user, spaceLink)const sendFile: SendFile = this.filesManager.sendFileFromSpace(spaceEnv, spaceLink.share.name)@@ -94,7 +94,7 @@ export class LinksManager {await sendFile.checks()return await sendFile.stream(req, res)} catch (e) {- this.logger.error(`${this.linkDownload.name} - unable to send file : ${e}`)+ this.logger.error({ tag: this.linkDownload.name, msg: `unable to send file : ${e}` })throw new HttpException('Unable to download file', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -102,18 +102,20 @@ export class LinksManager {async linkAuthentication(identity: JwtIdentityPayload, uuid: string, linkPasswordDto: UserPasswordDto, req: FastifyRequest, res: FastifyReply) {const [link, check, ok] = await this.linkEnv(identity, uuid, true)if (!ok) {- this.logger.warn(`${this.linkAuthentication.name} - *${link.user.login}* (${link.user.id}) : ${check}`)+ this.logger.warn({ tag: this.linkAuthentication.name, msg: `*${link.user.login}* (${link.user.id}) : ${check}` })throw new HttpException(check as string, HttpStatus.BAD_REQUEST)}const authSuccess: boolean = await this.usersManager.compareUserPassword(link.user.id, linkPasswordDto.password)const user = new UserModel(link.user)- this.usersManager.updateAccesses(user, req.ip, authSuccess).catch((e: Error) => this.logger.error(`${this.linkAuthentication.name} - ${e}`))+ this.usersManager+ .updateAccesses(user, req.ip, authSuccess)+ .catch((e: Error) => this.logger.error({ tag: this.linkAuthentication.name, msg: `${e}` }))if (!authSuccess) {- this.logger.warn(`${this.linkAuthentication.name} - *${user.login}* (${user.id}) : auth failed`)+ this.logger.warn({ tag: this.linkAuthentication.name, msg: `*${user.login}* (${user.id}) : auth failed` })throw new HttpException(LINK_ERROR.UNAUTHORIZED, HttpStatus.FORBIDDEN)}// authenticate user to allow access- this.logger.log(`${this.linkAuthentication.name} - *${user.login}* (${user.id}) is logged`)+ this.logger.log({ tag: this.linkAuthentication.name, msg: `*${user.login}* (${user.id}) is logged` })return this.authManager.setCookies(user, res)}@@ -151,6 +153,6 @@ export class LinksManager {}private incrementLinkNbAccess(link: LinkAsUser) {- this.linksQueries.incrementLinkNbAccess(link.uuid).catch((e: Error) => this.logger.error(`${this.incrementLinkNbAccess.name} - ${e}`))+ this.linksQueries.incrementLinkNbAccess(link.uuid).catch((e: Error) => this.logger.error({ tag: this.incrementLinkNbAccess.name, msg: `${e}` }))}}diff --git a/backend/src/applications/notifications/services/notifications-manager.service.ts b/backend/src/applications/notifications/services/notifications-manager.service.tsindex 2b3d1369..68935c40 100644--- a/backend/src/applications/notifications/services/notifications-manager.service.ts+++ b/backend/src/applications/notifications/services/notifications-manager.service.ts@@ -42,7 +42,7 @@ export class NotificationsManager {// store it in dbconst isArrayOfUsers: boolean = typeof toUsers[0] === 'object'const toUserIds = isArrayOfUsers ? (toUsers as UserMailNotification[]).map((m) => m.id) : (toUsers as number[])- this.storeNotification(toUserIds, content, options?.author?.id).catch((e: Error) => this.logger.error(`${this.create.name} - ${e}`))+ this.storeNotification(toUserIds, content, options?.author?.id).catch((e: Error) => this.logger.error({ tag: this.create.name, msg: `${e}` }))// send websocket notificationthis.webSocketNotifications.sendMessageToUsers(toUserIds, NOTIFICATIONS_WS.EVENTS.NOTIFICATION, 'check')@@ -55,12 +55,14 @@ export class NotificationsManager {if (!usersNotifiedByEmail.length) {return}- this.sendEmailNotification(usersNotifiedByEmail, content, options).catch((e: Error) => this.logger.error(`${this.create.name} - ${e}`))+ this.sendEmailNotification(usersNotifiedByEmail, content, options).catch((e: Error) =>+ this.logger.error({ tag: this.create.name, msg: `${e}` })+ )}}wasRead(user: UserModel, notificationId?: number): void {- this.notificationsQueries.wasRead(user.id, notificationId).catch((e: Error) => this.logger.error(`${this.wasRead.name} - ${e}`))+ this.notificationsQueries.wasRead(user.id, notificationId).catch((e: Error) => this.logger.error({ tag: this.wasRead.name, msg: `${e}` }))}async delete(user: UserModel, notificationId?: number): Promise<void> {@@ -87,7 +89,7 @@ export class NotificationsManager {})))- .catch((e: Error) => this.logger.error(`${this.sendEmailNotification.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.sendEmailNotification.name, msg: `${e}` }))}private async storeNotification(toUserIds: number[], content: NotificationContent, authorId?: number): Promise<void> {@@ -95,7 +97,7 @@ export class NotificationsManager {try {await this.notificationsQueries.create(authorId || null, toUserIds, content)} catch (e) {- this.logger.error(`${this.create.name} - ${e}`)+ this.logger.error({ tag: this.storeNotification.name, msg: `${e}` })}}@@ -128,7 +130,7 @@ export class NotificationsManager {case NOTIFICATION_APP.UPDATE_AVAILABLE:return serverUpdateAvailableMail(language, content)default:- this.logger.error(`${this.genMail.name} - case not handled : ${content.app}`)+ this.logger.error({ tag: this.genMail.name, msg: `case not handled : ${content.app}` })}}}diff --git a/backend/src/applications/shares/services/shares-manager.service.ts b/backend/src/applications/shares/services/shares-manager.service.tsindex f237c103..14bc8cfe 100644--- a/backend/src/applications/shares/services/shares-manager.service.ts+++ b/backend/src/applications/shares/services/shares-manager.service.ts@@ -87,7 +87,7 @@ export class SharesManager {// retrieve space permissions (cached query)const spacePermissions: Partial<SpaceEnv> = await this.spacesQueries.permissions(user.id, share.file.space.alias, share.file.space.root?.alias)if (!spacePermissions) {- this.logger.warn(`${this.setAllowedPermissions.name} - missing space permissions : ${JSON.stringify(share)}`)+ this.logger.warn({ tag: this.setAllowedPermissions.name, msg: `missing space permissions : ${JSON.stringify(share)}` })throw new HttpException('Space not found', HttpStatus.NOT_FOUND)}// compute permissions@@ -100,12 +100,12 @@ export class SharesManager {const userId = asAdmin ? share.ownerId : user.idconst sharePermissions: Partial<SpaceEnv> = await this.sharesQueries.permissions(userId, share.parent.alias, +user.isAdmin)if (!sharePermissions) {- this.logger.warn(`${this.setAllowedPermissions.name} - missing share permissions : ${JSON.stringify(share)}`)+ this.logger.warn({ tag: this.setAllowedPermissions.name, msg: `missing share permissions : ${JSON.stringify(share)}` })throw new HttpException('Share not found', HttpStatus.NOT_FOUND)}share.file.permissions = sharePermissions.permissions} else {- this.logger.error(`${this.setAllowedPermissions.name} - case not handled ${JSON.stringify(share)}`)+ this.logger.error({ tag: this.setAllowedPermissions.name, msg: `case not handled ${JSON.stringify(share)}` })throw new HttpException('Missing information', HttpStatus.BAD_REQUEST)}}@@ -158,7 +158,7 @@ export class SharesManager {}const realPath = path.join(user.filesPath, createOrUpdateShareDto.file.path)if (!(await isPathExists(realPath))) {- this.logger.warn(`${this.createShare.name} - location does not exist : ${realPath}`)+ this.logger.warn({ tag: this.createShare.name, msg: `location does not exist : ${realPath}` })throw new HttpException('The location does not exist', HttpStatus.NOT_FOUND)}const fileProps: FileProps = { ...(await getProps(realPath, createOrUpdateShareDto.file.path)), id: createOrUpdateShareDto.file.id }@@ -194,7 +194,7 @@ export class SharesManager {throw new HttpException(e.message, HttpStatus.BAD_REQUEST)}if (!(await isPathExists(space.realPath))) {- this.logger.warn(`${this.createShare.name} - space location does not exist : *${space.alias}* (${space.id}) : ${space.realPath}`)+ this.logger.warn({ tag: this.createShare.name, msg: `space location does not exist : *${space.alias}* (${space.id}) : ${space.realPath}` })throw new HttpException('The location does not exist', HttpStatus.NOT_FOUND)}share.spaceId = space.id@@ -268,7 +268,7 @@ export class SharesManager {await this.deleteAllLinkMembers(shareId, LINK_TYPE.SHARE)await this.removeShareFromOwners(shareId, 'all', false, user.id)} catch (e) {- this.logger.error(`${this.deleteShare.name} - unable to delete share (${shareId}) (asAdmin = ${asAdmin}) : ${e}`)+ this.logger.error({ tag: this.deleteShare.name, msg: `unable to delete share (${shareId}) (asAdmin = ${asAdmin}) : ${e}` })throw new HttpException('Unable to delete share', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -300,15 +300,21 @@ export class SharesManager {// check parent shareconst pSharePermissions = await this.sharesQueries.permissions(user.id, createOrUpdateShareDto.parent.alias, +user.isAdmin)if (!pSharePermissions) {- this.logger.warn(`${this.createChildShare.name} - parent share does not exist or not authorized : ${createOrUpdateShareDto.parent.alias}`)+ this.logger.warn({+ tag: this.createChildShare.name,+ msg: `parent share does not exist or not authorized : ${createOrUpdateShareDto.parent.alias}`+ })throw new HttpException('Parent share not found', HttpStatus.NOT_FOUND)}if (!haveSpacePermission(pSharePermissions, SPACE_OPERATION.SHARE_OUTSIDE)) {- this.logger.warn(`${this.createChildShare.name} - is not allowed to share outside of : *${pSharePermissions.alias}* (${pSharePermissions.id})`)+ this.logger.warn({+ tag: this.createChildShare.name,+ msg: `is not allowed to share outside of : *${pSharePermissions.alias}* (${pSharePermissions.id})`+ })throw new HttpException('You are not allowed to do this action', HttpStatus.FORBIDDEN)}if (!pSharePermissions.enabled) {- this.logger.warn(`${this.createChildShare.name} - parent share is disabled : ${createOrUpdateShareDto.parent.alias}`)+ this.logger.warn({ tag: this.createChildShare.name, msg: `parent share is disabled : ${createOrUpdateShareDto.parent.alias}` })throw new HttpException('Parent share is disabled', HttpStatus.FORBIDDEN)}@@ -317,9 +323,10 @@ export class SharesManager {if (pSharePermissions.root.externalPath) {const highestParentId = await this.sharesQueries.findHighestParentShare(pSharePermissions.id)if (!highestParentId) {- this.logger.warn(- `${this.createChildShare.name} - unable to find the highest parent of : *${pSharePermissions.alias}* (${pSharePermissions.id})`- )+ this.logger.warn({+ tag: this.createChildShare.name,+ msg: `unable to find the highest parent of : *${pSharePermissions.alias}* (${pSharePermissions.id})`+ })throw new HttpException('Parent share not found', HttpStatus.NOT_FOUND)}pShare = await this.sharesQueries.shareEnv(highestParentId)@@ -341,9 +348,10 @@ export class SharesManager {}// check fileif (!(await isPathExists(pShareEnv.realPath))) {- this.logger.warn(- `${this.createChildShare.name} - parent share location does not exist : ${pShareEnv.alias} (${pShareEnv.id}) : ${pShareEnv.realPath}`- )+ this.logger.warn({+ tag: this.createChildShare.name,+ msg: `parent share location does not exist : ${pShareEnv.alias} (${pShareEnv.id}) : ${pShareEnv.realPath}`+ })throw new HttpException('The location does not exist', HttpStatus.NOT_FOUND)}@@ -457,13 +465,16 @@ export class SharesManager {}],false- ).catch((e: Error) => this.logger.error(`${this.updateSharesFromSpace.name} - ${e}`))+ ).catch((e: Error) => this.logger.error({ tag: this.updateSharesFromSpace.name, msg: `${e}` }))} else {this.removeShareFromOwners(share.id, [share.ownerId], false).catch((e: Error) =>- this.logger.error(`${this.updateSharesFromSpace.name} - ${e}`)+ this.logger.error({ tag: this.updateSharesFromSpace.name, msg: `${e}` }))}- this.logger.log(`${this.updateSharesFromSpace.name} - ${action.type} share (${share.id}) for owner ${share.ownerId} from space ${spaceId}`)+ this.logger.log({+ tag: this.updateSharesFromSpace.name,+ msg: `${action.type} share (${share.id}) for owner ${share.ownerId} from space ${spaceId}`+ })}}}@@ -491,7 +502,7 @@ export class SharesManager {}],false- ).catch((e: Error) => this.logger.error(`${this.updateSharesFromSpaceRoots.name} - ${e}`))+ ).catch((e: Error) => this.logger.error({ tag: this.updateSharesFromSpaceRoots.name, msg: `${e}` }))}}@@ -543,7 +554,7 @@ export class SharesManager {linkGuest = await this.linksQueries.linkFromShare(user.id, linkId, spaceOrShareId, +user.isAdmin)}if (!linkGuest) {- this.logger.warn(`${this.getLinkFromSpaceOrShare.name} - unable to find link (${linkId}) on ${type} (${spaceOrShareId})`)+ this.logger.warn({ tag: this.getLinkFromSpaceOrShare.name, msg: `unable to find link (${linkId}) on ${type} (${spaceOrShareId})` })throw new HttpException('Link not found', HttpStatus.NOT_FOUND)}return linkGuest@@ -566,7 +577,7 @@ export class SharesManager {})// notify the guest link (if email is specified)this.notifyGuestLink(user, link, spaceOrShare.name, type === LINK_TYPE.SHARE ? ACTION.ADD : ACTION.UPDATE).catch((e: Error) =>- this.logger.error(`${this.createOrUpdateLinksAsMembers.name} - ${e}`)+ this.logger.error({ tag: this.createOrUpdateLinksAsMembers.name, msg: `${e}` }))} else {if (link.linkSettings) {@@ -590,7 +601,10 @@ export class SharesManager {): Promise<LinkGuest> {const link: LinkGuest = await this.getLinkFromSpaceOrShare(user, linkId, spaceOrShareId, type)if (!link) {- this.logger.error(`${this.updateLinkFromSpaceOrShare.name} - (${linkId}) from ${type} (${spaceOrShareId}) and user (${user.id}) was not found`)+ this.logger.error({+ tag: this.updateLinkFromSpaceOrShare.name,+ msg: `(${linkId}) from ${type} (${spaceOrShareId}) and user (${user.id}) was not found`+ })throw new HttpException('Unable to find link', HttpStatus.NOT_FOUND)}const fieldsWhiteList: (keyof CreateOrUpdateLinkDto)[] = [@@ -628,7 +642,7 @@ export class SharesManager {updateMember.permissions = intersectPermissions(shareLink.file.permissions, v)this.sharesQueries.clearCachePermissions(shareLink.alias, [link.userId])- .catch((e: Error) => this.logger.error(`${this.updateLinkFromSpaceOrShare.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.updateLinkFromSpaceOrShare.name, msg: `${e}` }))}breakcase 'language':@@ -655,21 +669,22 @@ export class SharesManager {}}if (!Object.keys(updateUser).length && !Object.keys(updateLink).length && !Object.keys(updateShare).length && !Object.keys(updateMember).length) {- this.logger.warn(`${this.updateLinkFromSpaceOrShare.name} - no diff to update`)+ this.logger.warn({ tag: this.updateLinkFromSpaceOrShare.name, msg: `no diff to update` })return fromAPI ? link : null}try {await this.linksQueries.updateLinkFromSpaceOrShare(link, spaceOrShareId, updateUser, updateLink, updateShare, updateMember)- this.logger.debug(- `${this.updateLinkFromSpaceOrShare.name} - link (${linkId}) updated : ${JSON.stringify({+ this.logger.debug({+ tag: this.updateLinkFromSpaceOrShare.name,+ msg: `link (${linkId}) updated : ${JSON.stringify({...{ user: anonymizePassword(updateUser) },...{ link: updateLink },...{ share: updateShare },...{ member: updateMember }})}`- )+ })} catch (e) {- this.logger.error(`${this.updateLinkFromSpaceOrShare.name} - ${e}`)+ this.logger.error({ tag: this.updateLinkFromSpaceOrShare.name, msg: `${e}` })throw new HttpException('Unable to update link', HttpStatus.INTERNAL_SERVER_ERROR)}if (fromAPI) {@@ -702,7 +717,7 @@ export class SharesManager {;(guestLink as Partial<User>).id = await this.usersQueries.createUserOrGuest(guestLink, USER_ROLE.LINK)return guestLink} catch (e) {- this.logger.error(`${this.createGuestLink.name} - unable to create guest link : ${e}`)+ this.logger.error({ tag: this.createGuestLink.name, msg: `unable to create guest link : ${e}` })throw new HttpException('Unable to create guest link', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -723,27 +738,26 @@ export class SharesManager {async updateSharesExternalPathQuota(shareId?: number): Promise<void | StorageQuota> {for (const share of await this.sharesQueries.sharesQuotaExternalPaths(shareId)) {if (!(await isPathExists(share.externalPath))) {- this.logger.warn(`${this.updateSharesExternalPathQuota.name} - *${share.alias}* home path does not exist`)+ this.logger.warn({ tag: this.updateSharesExternalPathQuota.name, msg: `*${share.alias}* home path does not exist` })continue}const [size, errors] = await dirSize(share.externalPath)for (const [path, error] of Object.entries(errors)) {- this.logger.warn(`${this.updateSharesExternalPathQuota.name} - unable to get size for *${share.alias}* on ${path} : ${error}`)+ this.logger.warn({ tag: this.updateSharesExternalPathQuota.name, msg: `unable to get size for *${share.alias}* on ${path} : ${error}` })}const shareQuota: StorageQuota = { storageUsage: size, storageQuota: share.storageQuota }this.sharesQueries.cache.set(`${CACHE_QUOTA_SHARE_PREFIX}-${share.id}`, shareQuota, CACHE_QUOTA_TTL)- .catch((e: Error) => this.logger.error(`${this.updateSharesExternalPathQuota.name} - share *${share.alias}* (${share.id}) : ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.updateSharesExternalPathQuota.name, msg: `share *${share.alias}* (${share.id}) : ${e}` }))if (share.storageUsage !== shareQuota.storageUsage) {- this.sharesQueries- .updateShare(share.id, { storageUsage: shareQuota.storageUsage })- .then(- (updated: boolean) =>- updated &&- this.logger.log(- `${this.updateSharesExternalPathQuota.name} - share *${share.alias}* (${share.id}) - storage usage updated : ${shareQuota.storageUsage}`- )- )+ this.sharesQueries.updateShare(share.id, { storageUsage: shareQuota.storageUsage }).then(+ (updated: boolean) =>+ updated &&+ this.logger.log({+ tag: this.updateSharesExternalPathQuota.name,+ msg: `share *${share.alias}* (${share.id}) - storage usage updated : ${shareQuota.storageUsage}`+ })+ )}if (shareId) {return shareQuota@@ -771,9 +785,10 @@ export class SharesManager {((m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST) && !m.linkId && userIdsWhitelist.indexOf(m.id) === -1) ||((m.type === MEMBER_TYPE.GROUP || m.type === MEMBER_TYPE.PGROUP) && groupIdsWhitelist.indexOf(m.id) === -1)) {- this.logger.warn(- `${this.updateMembers.name} cannot add ${m.type} (${m.id}) to share *${share.alias}* (${share.id}) : not in the members whitelist`- )+ this.logger.warn({+ tag: this.updateMembers.name,+ msg: `cannot add ${m.type} (${m.id}) to share *${share.alias}* (${share.id}) : not in the members whitelist`+ })return false}return true@@ -783,7 +798,7 @@ export class SharesManager {// filter linksconst toRemove = remove.filter((m) => !m.linkId)// do remove links- this.deleteLinkMembers(remove.filter((m) => !!m.linkId)).catch((e: Error) => this.logger.error(`${this.updateMembers.name} - ${e}`))+ this.deleteLinkMembers(remove.filter((m) => !!m.linkId)).catch((e: Error) => this.logger.error({ tag: this.updateMembers.name, msg: `${e}` }))// do update membersconst status: Record<Exclude<ACTION, ACTION.DELETE_PERMANENTLY>,@@ -822,13 +837,13 @@ export class SharesManager {}// clear cache &|| notify- this.onShareActionForMembers(share, action, members, user).catch((e: Error) => this.logger.error(`${this.updateMembers.name} - ${e}`))+ this.onShareActionForMembers(share, action, members, user).catch((e: Error) => this.logger.error({ tag: this.updateMembers.name, msg: `${e}` }))}// do updates// remove or update potential child sharesthis.updateMembersChildSharesPermissions(share.id, currentMembers, rmMembersChildShares, upMembersChildShares).catch((e: Error) =>- this.logger.error(`${this.updateMembers.name} - ${e}`)+ this.logger.error({ tag: this.updateMembers.name, msg: `${e}` }))}@@ -871,9 +886,10 @@ export class SharesManager {havePermission(m.permissions, SPACE_OPERATION.SHARE_OUTSIDE))if (groupSharePermission) {- this.logger.debug(- `${this.diffSharesPermissions.name} - ignore user (${m.id}) removal : is a member of the group (${groupSharePermission.id}) with share permission`- )+ this.logger.debug({+ tag: this.diffSharesPermissions.name,+ msg: `ignore user (${m.id}) removal : is a member of the group (${groupSharePermission.id}) with share permission`+ })continue}removeUsersChildShares.push(m.id)@@ -988,18 +1004,22 @@ export class SharesManager {// store current child shares members before delete parent shareconst members: ShareChildMember[] = await this.sharesQueries.membersFromChildSharesPermissions(share.id, [share.ownerId], null, false)await this.sharesQueries.deleteShare(share.id)- this.logger.log(`${this.removeShareFromOwners.name} - share *${share.alias}* (${share.id}) from owner (${share.ownerId}) was removed`)+ this.logger.log({+ tag: this.removeShareFromOwners.name,+ msg: `share *${share.alias}* (${share.id}) from owner (${share.ownerId}) was removed`+ })// clear cache and notify usersif (share.ownerId && (!fromUserId || fromUserId !== share.ownerId)) {this.clearCachePermissionsAndOrNotify(share, ACTION.DELETE_PERMANENTLY, [share.ownerId]).catch((e: Error) =>- this.logger.error(`${this.removeShareFromOwners.name} - ${e}`)+ this.logger.error({ tag: this.removeShareFromOwners.name, msg: `${e}` }))}members.forEach((m) => this.clearCachePermissionsAndOrNotify({ alias: m.shareAlias, name: m.shareName }, ACTION.DELETE, [m.userId]))} catch (e) {- this.logger.error(- `${this.removeShareFromOwners.name} - share *${share.alias}* (${share.id}) from owner (${share.ownerId}) was not removed : ${e}`- )+ this.logger.error({+ tag: this.removeShareFromOwners.name,+ msg: `share *${share.alias}* (${share.id}) from owner (${share.ownerId}) was not removed : ${e}`+ })}}}@@ -1032,14 +1052,16 @@ export class SharesManager {},ACTION.UPDATE,[m.userId]- ).catch((e: Error) => this.logger.error(`${this.removeChildSharesPermissions.name} - ${e}`))- this.logger.log(- `${this.removeChildSharesPermissions.name} - user (${m.id}) permissions ${JSON.stringify(userPerm.rmPermissions)} on share : ${m.shareAlias} (${m.shareId}) was removed`- )+ ).catch((e: Error) => this.logger.error({ tag: this.removeChildSharesPermissions.name, msg: `${e}` }))+ this.logger.log({+ tag: this.removeChildSharesPermissions.name,+ msg: `user (${m.id}) permissions ${JSON.stringify(userPerm.rmPermissions)} on share : ${m.shareAlias} (${m.shareId}) was removed`+ })} catch (e) {- this.logger.error(- `${this.removeChildSharesPermissions.name} - user (${m.id}) permissions on share *${m.shareAlias}* (${m.shareId}) was not removed : ${e}`- )+ this.logger.error({+ tag: this.removeChildSharesPermissions.name,+ msg: `user (${m.id}) permissions on share *${m.shareAlias}* (${m.shareId}) was not removed : ${e}`+ })}}}@@ -1048,7 +1070,10 @@ export class SharesManager {private async checkChildSharePermissions(user: UserModel, shareId: number, childId: number): Promise<boolean> {const isOwnerForChildShare: number = await this.sharesQueries.childExistsForShareOwner(user.id, shareId, childId, user.isAdmin)if (isOwnerForChildShare !== childId) {- this.logger.warn(`${this.checkChildSharePermissions.name} - is not allowed to manage child share (${childId}) from share (${shareId})`)+ this.logger.warn({+ tag: this.checkChildSharePermissions.name,+ msg: `is not allowed to manage child share (${childId}) from share (${shareId})`+ })throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)}return true@@ -1062,7 +1087,7 @@ export class SharesManager {(uid) => uid !== user?.id),user- ).catch((e: Error) => this.logger.error(`${this.onShareActionForMembers.name} - ${e}`))+ ).catch((e: Error) => this.logger.error({ tag: this.onShareActionForMembers.name, msg: `${e}` }))}private async createLinkFromSpaceOrShare(@@ -1074,7 +1099,7 @@ export class SharesManager {): Promise<void> {/* only used during the share creation from this manager */if (!(await this.linksQueries.isReservedUUID(user.id, uuid))) {- this.logger.error(`${this.createLinkFromSpaceOrShare.name} - user attempted to use UUID (${uuid}) was not reserved`)+ this.logger.error({ tag: this.createLinkFromSpaceOrShare.name, msg: `user attempted to use UUID (${uuid}) was not reserved` })throw new HttpException('UUID was not reserved', HttpStatus.BAD_REQUEST)}const permission = type === LINK_TYPE.SPACE ? GUEST_PERMISSION.SPACES : GUEST_PERMISSION.SHARES@@ -1084,7 +1109,7 @@ export class SharesManager {createOrUpdateLinkDto.language,createOrUpdateLinkDto.isActive !== undefined ? createOrUpdateLinkDto.isActive : true)- this.logger.debug(`${this.createLinkFromSpaceOrShare.name} - guest link (${guestLink.id}) created`)+ this.logger.debug({ tag: this.createLinkFromSpaceOrShare.name, msg: `guest link (${guestLink.id}) created` })let linkId: numbertry {linkId = await this.linksQueries.createLinkToSpaceOrShare(guestLink.id, spaceOrShareId, type, {@@ -1092,11 +1117,12 @@ export class SharesManager {uuid: uuid,userId: guestLink.id})- this.logger.debug(- `${this.createLinkFromSpaceOrShare.name} - link (${linkId}) for guest link (${guestLink.id}) created : ${JSON.stringify(createOrUpdateLinkDto)}`- )+ this.logger.debug({+ tag: this.createLinkFromSpaceOrShare.name,+ msg: `link (${linkId}) for guest link (${guestLink.id}) created : ${JSON.stringify(createOrUpdateLinkDto)}`+ })} catch (e) {- this.logger.error(`${this.createLinkFromSpaceOrShare.name} - unable to create link with uuid (${uuid}) : ${e}`)+ this.logger.error({ tag: this.createLinkFromSpaceOrShare.name, msg: `unable to create link with uuid (${uuid}) : ${e}` })throw new HttpException('Unable to update link', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -1105,9 +1131,9 @@ export class SharesManager {for (const guestLink of guestLinks) {try {await this.usersQueries.deleteGuestLink(guestLink.id)- this.logger.log(`${this.deleteGuestLinks.name} - guest (${guestLink.id}) (link: ${guestLink.linkId}) was removed`)+ this.logger.log({ tag: this.deleteGuestLinks.name, msg: `guest (${guestLink.id}) (link: ${guestLink.linkId}) was removed` })} catch (e) {- this.logger.error(`${this.deleteGuestLinks.name} - guest (${guestLink.id}) (link: ${guestLink.linkId}) was not removed : ${e}`)+ this.logger.error({ tag: this.deleteGuestLinks.name, msg: `guest (${guestLink.id}) (link: ${guestLink.linkId}) was not removed : ${e}` })}}}@@ -1118,12 +1144,15 @@ export class SharesManager {if (!memberIds?.length) {return}- this.logger.verbose(`${this.clearCachePermissionsAndOrNotify.name} - share:${share.alias} ${action} members:${JSON.stringify(memberIds)}`)+ this.logger.verbose({+ tag: this.clearCachePermissionsAndOrNotify.name,+ msg: `share:${share.alias} ${action} members:${JSON.stringify(memberIds)}`+ })if (action !== ACTION.ADD) {// clear permissions for share membersthis.sharesQueries.clearCachePermissions(share.alias, memberIds)- .catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `${e}` }))}if (action !== ACTION.UPDATE) {// notify the members who have joined or left the share@@ -1139,7 +1168,7 @@ export class SharesManager {author: user,action: action})- .catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `${e}` }))}}@@ -1171,6 +1200,6 @@ export class SharesManager {action: action} satisfies NotificationOptions)- .catch((e: Error) => this.logger.error(`${this.notifyGuestLink.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.notifyGuestLink.name, msg: `${e}` }))}}diff --git a/backend/src/applications/shares/services/shares-queries.service.ts b/backend/src/applications/shares/services/shares-queries.service.tsindex 501c706b..8c1c8229 100644--- a/backend/src/applications/shares/services/shares-queries.service.ts+++ b/backend/src/applications/shares/services/shares-queries.service.ts@@ -310,10 +310,10 @@ export class SharesQueries {async updateShare(id: number, set: Partial<Record<keyof Share, any>>): Promise<boolean> {try {dbCheckAffectedRows(await this.db.update(shares).set(set).where(eq(shares.id, id)).limit(1), 1)- this.logger.debug(`${this.updateShare.name} - share (${id}) was updated : ${JSON.stringify(set)}`)+ this.logger.debug({ tag: this.updateShare.name, msg: `share (${id}) was updated : ${JSON.stringify(set)}` })return true} catch (e) {- this.logger.error(`${this.updateShare.name} - share (${id}) was not updated : ${JSON.stringify(set)} : ${e}`)+ this.logger.error({ tag: this.updateShare.name, msg: `share (${id}) was not updated : ${JSON.stringify(set)} : ${e}` })return false}}@@ -333,10 +333,10 @@ export class SharesQueries {.limit(1),1)- this.logger.debug(`${this.updateMember.name} - ${JSON.stringify(filters)} was updated : ${JSON.stringify(set)}`)+ this.logger.debug({ tag: this.updateMember.name, msg: `${JSON.stringify(filters)} was updated : ${JSON.stringify(set)}` })return true} catch (e) {- this.logger.error(`${this.updateMember.name} - ${JSON.stringify(filters)} was not updated : ${JSON.stringify(set)} : ${e}`)+ this.logger.error({ tag: this.updateMember.name, msg: `${JSON.stringify(filters)} was not updated : ${JSON.stringify(set)} : ${e}` })return false}}@@ -365,9 +365,9 @@ export class SharesQueries {1)status[ACTION.ADD][`${m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST ? 'userIds' : 'groupIds'}`].push(m.id)- this.logger.debug(`${this.updateMembers.name} - ${m.type} (${m.id}) added to the share (${shareId})`)+ this.logger.debug({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) added to the share (${shareId})` })} catch (e) {- this.logger.error(`${this.updateMembers.name} - ${m.type} (${m.id}) was not added to the share (${shareId}) -> : ${e}`)+ this.logger.error({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) was not added to the share (${shareId}) -> : ${e}` })}}// update@@ -388,9 +388,12 @@ export class SharesQueries {1)status[ACTION.UPDATE][`${m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST ? 'userIds' : 'groupIds'}`].push(m.id)- this.logger.debug(`${this.updateMembers.name} - ${m.type} (${m.id}) was updated on share (${shareId}) : ${JSON.stringify(props)}`)+ this.logger.debug({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) was updated on share (${shareId}) : ${JSON.stringify(props)}` })} catch (e) {- this.logger.error(`${this.updateMembers.name} - ${m.type} (${m.id}) was not updated on share (${shareId}) : ${JSON.stringify(props)} : ${e}`)+ this.logger.error({+ tag: this.updateMembers.name,+ msg: `${m.type} (${m.id}) was not updated on share (${shareId}) : ${JSON.stringify(props)} : ${e}`+ })}}// remove@@ -408,9 +411,9 @@ export class SharesQueries {1)status[ACTION.DELETE][`${m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST ? 'userIds' : 'groupIds'}`].push(m.id)- this.logger.debug(`${this.updateMembers.name} - ${m.type} (${m.id}) removed from share (${shareId})`)+ this.logger.debug({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) removed from share (${shareId})` })} catch (e) {- this.logger.error(`${this.updateMembers.name} - ${m.type} (${m.id}) was not removed from share (${shareId}) : ${e}`)+ this.logger.error({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) was not removed from share (${shareId}) : ${e}` })}}return status@@ -902,8 +905,8 @@ export class SharesQueries {const pattern = this.cache.genSlugKey(this.constructor.name, this.permissions.name, userId, shareAlias, '*')const keys = await this.cache.keys(pattern)if (keys.length) {- this.logger.verbose(`${this.clearCachePermissions.name} - ${JSON.stringify(keys)}`)- this.cache.mdel(keys).catch((e: Error) => this.logger.error(`${this.clearCachePermissions.name} - ${e}`))+ this.logger.verbose({ tag: this.clearCachePermissions.name, msg: `${JSON.stringify(keys)}` })+ this.cache.mdel(keys).catch((e: Error) => this.logger.error({ tag: this.clearCachePermissions.name, msg: `${e}` }))}}}diff --git a/backend/src/applications/spaces/guards/space.guard.ts b/backend/src/applications/spaces/guards/space.guard.tsindex 51af1a5d..dcf8fcff 100644--- a/backend/src/applications/spaces/guards/space.guard.ts+++ b/backend/src/applications/spaces/guards/space.guard.ts@@ -70,11 +70,11 @@ export class SpaceGuard implements CanActivate {try {space = await this.spacesManager.spaceEnv(req.user, urlSegments)} catch (e) {- this.logger.warn(`${this.canActivate.name} - ${e}`)+ this.logger.warn({ tag: this.canActivate.name, msg: `${e}` })throw new HttpException('Space path is not valid', HttpStatus.BAD_REQUEST)}if (!space) {- this.logger.warn(`${this.canActivate.name} - space not authorized or not found : ${req.params['*']}`)+ this.logger.warn({ tag: this.canActivate.name, msg: `space not authorized or not found : ${req.params['*']}` })throw new HttpException('Space not found', HttpStatus.NOT_FOUND)}if (!space.enabled) {@@ -101,14 +101,14 @@ export class SpaceGuard implements CanActivate {}return PATH_TO_SPACE_SEGMENTS(req.params['*'])} catch (e) {- this.logger.warn(`${this.canActivate.name} - ${e}`)+ this.logger.warn({ tag: this.canActivate.name, msg: `${e}` })throw new HttpException(e.message, HttpStatus.NOT_FOUND)}}private checkAccessToSpace(req: FastifySpaceRequest, urlSegments: string[]) {if (!canAccessToSpaceUrl(req.user, urlSegments)) {- this.logger.warn(`is not allowed to access to this space repository : ${req.params['*']}`)+ this.logger.warn({ tag: this.checkAccessToSpace.name, msg: `is not allowed to access to this space repository : ${req.params['*']}` })throw new HttpException('You are not allowed to access to this repository', HttpStatus.FORBIDDEN)}}diff --git a/backend/src/applications/spaces/services/spaces-browser.service.ts b/backend/src/applications/spaces/services/spaces-browser.service.tsindex b6f1170d..6cac9a49 100644--- a/backend/src/applications/spaces/services/spaces-browser.service.ts+++ b/backend/src/applications/spaces/services/spaces-browser.service.ts@@ -67,7 +67,7 @@ export class SpacesBrowser {await this.enrichWithLocks(space, spaceFiles.files)}// update recents files- this.filesRecents.updateRecents(user, space, spaceFiles.files).catch((e: Error) => this.logger.error(`${this.browse.name} - ${e}`))+ this.filesRecents.updateRecents(user, space, spaceFiles.files).catch((e: Error) => this.logger.error({ tag: this.browse.name, msg: `${e}` }))return spaceFiles}@@ -117,7 +117,7 @@ export class SpacesBrowser {try {await IsRealPathIsDirAndExists(space.realPath)} catch (e) {- this.logger.warn(`${this.parseFS.name} - ${space.realPath} : ${e.message}`)+ this.logger.warn({ tag: this.parseFS.name, msg: `${space.realPath} : ${e.message}` })throw new HttpException(e.message, e.httpCode)}for await (const f of this.parsePath(space)) {@@ -131,11 +131,11 @@ export class SpacesBrowser {for (const element of await fs.readdir(space.realPath, { withFileTypes: true })) {const isDir = element.isDirectory()if (!isDir && !element.isFile()) {- this.logger.log(`${this.parsePath.name} - ignore special file : ${element.name}`)+ this.logger.log({ tag: this.parsePath.name, msg: `ignore special file : ${element.name}` })continue}if (!configuration.applications.files.showHiddenFiles && element.name[0] === '.') {- this.logger.verbose(`${this.parsePath.name} - ignore filtered file : ${element.name}`)+ this.logger.verbose({ tag: this.parsePath.name, msg: `ignore filtered file : ${element.name}` })continue}const realPath = path.join(space.realPath, element.name)@@ -143,11 +143,11 @@ export class SpacesBrowser {try {yield await getProps(realPath, filePath, isDir)} catch (e) {- this.logger.warn(`${this.parsePath.name} - unable get stats from ${realPath} : ${e}`)+ this.logger.warn({ tag: this.parsePath.name, msg: `unable get stats from ${realPath} : ${e}` })}}} catch (e) {- this.logger.error(`${this.parsePath.name} - unable to parse ${space.realPath} : ${e}`)+ this.logger.error({ tag: this.parsePath.name, msg: `unable to parse ${space.realPath} : ${e}` })}}@@ -192,7 +192,9 @@ export class SpacesBrowser {// check `f.id`; it can be null for external rootsif (f.id) {// todo: check if a db file referenced under external roots have an id and correctly parsed here- this.filesQueries.compareAndUpdateFileProps(f, fileProps).catch((e: Error) => this.logger.error(`${this.updateRootFile.name} - ${e}`))+ this.filesQueries+ .compareAndUpdateFileProps(f, fileProps)+ .catch((e: Error) => this.logger.error({ tag: this.updateRootFile.name, msg: `${e}` }))fileProps.id = f.id}fileProps.root = {@@ -205,7 +207,7 @@ export class SpacesBrowser {}return fileProps} catch (e) {- this.logger.error(`${this.updateRootFile.name} - ${JSON.stringify(f)} - ${e}`)+ this.logger.error({ tag: this.updateRootFile.name, msg: `${JSON.stringify(f)} - ${e}` })return { ...f, name: fileName(f.path), path: dirName(f.path), ...{ root: { ...f.root, enabled: false } } }}}@@ -236,33 +238,39 @@ export class SpacesBrowser {if (options.withHasComments) {fsFile.hasComments = dbFile.hasComments}- this.filesQueries.compareAndUpdateFileProps(dbFile, fsFile).catch((e: Error) => this.logger.error(`${this.updateDBFiles.name} - ${e}`))+ this.filesQueries+ .compareAndUpdateFileProps(dbFile, fsFile)+ .catch((e: Error) => this.logger.error({ tag: this.updateDBFiles.name, msg: `${e}` }))} else {- this.logger.warn(`${this.updateDBFiles.name} - missing ${dbFile.path}/${dbFile.name} (${dbFile.id}) from fs, delete it from db`)+ this.logger.warn({ tag: this.updateDBFiles.name, msg: `missing ${dbFile.path}/${dbFile.name} (${dbFile.id}) from fs, delete it from db` })if (options.withSpacesAndShares) {if (dbFile.spaces) {for (const space of dbFile.spaces) {- this.logger.warn(- `${this.updateDBFiles.name} - ${dbFile.path}/${dbFile.name} (${dbFile.id}) will be removed from space : *${space.alias}* (${space.id})`- )+ this.logger.warn({+ tag: this.updateDBFiles.name,+ msg: `${dbFile.path}/${dbFile.name} (${dbFile.id}) will be removed from space : *${space.alias}* (${space.id})`+ })}}if (dbFile.shares) {for (const share of dbFile.shares) {- this.logger.warn(- `${this.updateDBFiles.name} - ${dbFile.path}/${dbFile.name} (${dbFile.id}) will be removed from share : *${share.alias}* (${share.id})`- )+ this.logger.warn({+ tag: this.updateDBFiles.name,+ msg: `${dbFile.path}/${dbFile.name} (${dbFile.id}) will be removed from share : *${share.alias}* (${share.id})`+ })}}}- this.deleteDBFile(user, space, dbFile).catch((e: Error) => this.logger.error(`${this.updateDBFiles.name} - ${e}`))+ this.deleteDBFile(user, space, dbFile).catch((e: Error) => this.logger.error({ tag: this.updateDBFiles.name, msg: `${e}` }))}}}private async deleteDBFile(user: UserModel, space: SpaceEnv, dbFile: FileProps) {const spaceEnv = await this.spacesManager.spaceEnv(user, path.join(space.url, dbFile.name).split('/'))- this.filesQueries.deleteFiles(spaceEnv.dbFile, dbFile.isDir, true).catch((e: Error) => this.logger.error(`${this.deleteDBFile.name} - ${e}`))+ this.filesQueries+ .deleteFiles(spaceEnv.dbFile, dbFile.isDir, true)+ .catch((e: Error) => this.logger.error({ tag: this.deleteDBFile.name, msg: `${e}` }))}private async mergeSpaceRootFiles(space: SpaceEnv, rootFiles: FileProps[], fsFiles: FileProps[], spaceFiles: SpaceFiles) {@@ -281,15 +289,15 @@ export class SpacesBrowser {true)if (newAlias) {- this.logger.log(`${this.mergeSpaceRootFiles.name} - update space root alias (${f.root.id}) : ${f.root.alias} -> ${newAlias}`)+ this.logger.log({ tag: this.mergeSpaceRootFiles.name, msg: `update space root alias (${f.root.id}) : ${f.root.alias} -> ${newAlias}` })// update in dbthis.spacesQueries.updateRoot({ alias: newAlias }, { id: f.root.id })- .catch((e: Error) => this.logger.error(`${this.mergeSpaceRootFiles.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.mergeSpaceRootFiles.name, msg: `${e}` }))// cleanup cachethis.spacesQueries.clearCachePermissions(space.alias, [f.root.alias, newAlias])- .catch((e: Error) => this.logger.error(`${this.mergeSpaceRootFiles.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.mergeSpaceRootFiles.name, msg: `${e}` }))// assignf.root.alias = newAlias}@@ -300,11 +308,11 @@ export class SpacesBrowser {fsFiles.map((f) => f.name))if (newName) {- this.logger.log(`${this.mergeSpaceRootFiles.name} - update space root name (${f.root.id}) : ${f.name} -> ${newName}`)+ this.logger.log({ tag: this.mergeSpaceRootFiles.name, msg: `update space root name (${f.root.id}) : ${f.name} -> ${newName}` })// update in dbthis.spacesQueries.updateRoot({ name: newName }, { id: f.root.id })- .catch((e: Error) => this.logger.error(`${this.mergeSpaceRootFiles.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.mergeSpaceRootFiles.name, msg: `${e}` }))// assignf.name = newName}diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.tsindex 0012af35..779a2519 100644--- a/backend/src/applications/spaces/services/spaces-manager.service.ts+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts@@ -137,7 +137,7 @@ export class SpacesManager {await this.setQuotaExceeded(user, space)return space} catch (e) {- this.logger.warn(`${this.spaceEnv.name} - *${space.alias}* : ${e}`)+ this.logger.warn({ tag: this.spaceEnv.name, msg: `*${space.alias}* : ${e}` })throw new HttpException(e.message, e instanceof FileError ? e.httpCode : HttpStatus.BAD_REQUEST)}}@@ -183,7 +183,7 @@ export class SpacesManager {trashes.push(space)}} catch (e) {- this.logger.error(`${this.listTrashes.name} - ${e}`)+ this.logger.error({ tag: this.listTrashes.name, msg: `${e}` })}}return trashes@@ -215,7 +215,7 @@ export class SpacesManager {try {space.id = await this.spacesQueries.createSpace(space)} catch (e) {- this.logger.error(`${this.createSpace.name} - unable to create space *${space.alias}* : ${e}`)+ this.logger.error({ tag: this.createSpace.name, msg: `unable to create space *${space.alias}* : ${e}` })throw new HttpException('Unable to create space', e)}// create space paths@@ -254,7 +254,7 @@ export class SpacesManager {}}// updates in db- this.spacesQueries.updateSpace(spaceId, spaceDiffProps).catch((e: Error) => this.logger.error(`${this.updateSpace.name} - ${e}`))+ this.spacesQueries.updateSpace(spaceId, spaceDiffProps).catch((e: Error) => this.logger.error({ tag: this.updateSpace.name, msg: `${e}` }))// checks & updates membersconst linkMembers: SpaceMemberDto[] = await this.sharesManager.createOrUpdateLinksAsMembers(user,@@ -293,9 +293,9 @@ export class SpacesManager {await this.sharesManager.deleteAllLinkMembers(spaceId, LINK_TYPE.SPACE)}await this.deleteOrDisableSpace(space, deleteNow)- this.logger.log(`${this.deleteSpace.name} - *${space.alias}* (${space.id}) was ${deleteNow ? 'deleted' : 'disabled'}`)+ this.logger.log({ tag: this.deleteSpace.name, msg: `*${space.alias}* (${space.id}) was ${deleteNow ? 'deleted' : 'disabled'}` })} catch (e) {- this.logger.error(`${this.deleteSpace.name} - *${space.alias}* (${space.id}) was not ${deleteNow ? 'deleted' : 'disabled'} : ${e}`)+ this.logger.error({ tag: this.deleteSpace.name, msg: `*${space.alias}* (${space.id}) was not ${deleteNow ? 'deleted' : 'disabled'} : ${e}` })throw new HttpException('Unable to delete space', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -308,7 +308,7 @@ export class SpacesManager {async updateUserRoots(user: UserModel, spaceId: number, userRoots: SpaceRootProps[], addOnly: boolean = false): Promise<SpaceRootProps[]> {const space: Partial<SpaceProps> = await this.userCanAccessSpace(user.id, spaceId)if (space.role !== SPACE_ROLE.IS_MANAGER && !haveSpacePermission(space, SPACE_OPERATION.SHARE_INSIDE)) {- this.logger.warn(`is not allowed to share inside on this space : *${space.alias}* (${space.id})`)+ this.logger.warn({ tag: this.updateUserRoots.name, msg: `is not allowed to share inside on this space : *${space.alias}* (${space.id})` })throw new HttpException('You are not allowed to do this action', HttpStatus.FORBIDDEN)}// current states@@ -330,7 +330,7 @@ export class SpacesManager {)Object.entries(status).forEach(([action, roots]: [ACTION, SpaceRootProps[]]) =>this.clearCachePermissionsAndOrNotify(space, action, user, null, roots).catch((e: Error) =>- this.logger.error(`${this.updateUserRoots.name} - ${e}`)+ this.logger.error({ tag: this.updateUserRoots.name, msg: `${e}` })))return this.getUserRoots(user, spaceId)@@ -369,27 +369,26 @@ export class SpacesManager {])) {const userPath = UserModel.getHomePath(user.login)if (!(await isPathExists(userPath))) {- this.logger.warn(`${this.updatePersonalSpacesQuota.name} - *${user.login}* home path does not exist`)+ this.logger.warn({ tag: this.updatePersonalSpacesQuota.name, msg: `*${user.login}* home path does not exist` })continue}const [size, errors] = await dirSize(userPath)for (const [path, error] of Object.entries(errors)) {- this.logger.warn(`${this.updatePersonalSpacesQuota.name} - unable to get size for *${user.login}* on ${path} : ${error}`)+ this.logger.warn({ tag: this.updatePersonalSpacesQuota.name, msg: `unable to get size for *${user.login}* on ${path} : ${error}` })}const spaceQuota: StorageQuota = { storageUsage: size, storageQuota: user.storageQuota }this.spacesQueries.cache.set(`${CACHE_QUOTA_USER_PREFIX}-${user.id}`, spaceQuota, CACHE_QUOTA_TTL)- .catch((e: Error) => this.logger.error(`${this.updatePersonalSpacesQuota.name} - user *${user.login}* (${user.id}) : ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.updatePersonalSpacesQuota.name, msg: `user *${user.login}* (${user.id}) : ${e}` }))if (user.storageUsage !== spaceQuota.storageUsage) {- this.usersQueries- .updateUserOrGuest(user.id, { storageUsage: spaceQuota.storageUsage })- .then(- (updated: boolean) =>- updated &&- this.logger.log(- `${this.updatePersonalSpacesQuota.name} - user *${user.login}* (${user.id}) - storage usage updated: ${spaceQuota.storageUsage}`- )- )+ this.usersQueries.updateUserOrGuest(user.id, { storageUsage: spaceQuota.storageUsage }).then(+ (updated: boolean) =>+ updated &&+ this.logger.log({+ tag: this.updatePersonalSpacesQuota.name,+ msg: `user *${user.login}* (${user.id}) - storage usage updated: ${spaceQuota.storageUsage}`+ })+ )}if (forUser) {return spaceQuota@@ -403,7 +402,7 @@ export class SpacesManager {for (const space of await this.spacesQueries.spacesQuotaPaths(spaceId)) {const spacePath = SpaceModel.getHomePath(space.alias)if (!(await isPathExists(spacePath))) {- this.logger.warn(`${this.updateSpacesQuota.name} - *${space.alias}* home path does not exist`)+ this.logger.warn({ tag: this.updateSpacesQuota.name, msg: `*${space.alias}* home path does not exist` })continue}let size = 0@@ -411,23 +410,22 @@ export class SpacesManager {const [rPathSize, errors] = await dirSize(rPath)size += rPathSizefor (const [path, error] of Object.entries(errors)) {- this.logger.warn(`${this.updateSpacesQuota.name} - unable to get size for *${space.alias}* on ${path} : ${error}`)+ this.logger.warn({ tag: this.updateSpacesQuota.name, msg: `unable to get size for *${space.alias}* on ${path} : ${error}` })}}const spaceQuota: StorageQuota = { storageUsage: size, storageQuota: space.storageQuota }this.spacesQueries.cache.set(`${CACHE_QUOTA_SPACE_PREFIX}-${space.id}`, spaceQuota, CACHE_QUOTA_TTL)- .catch((e: Error) => this.logger.error(`${this.updateSpacesQuota.name} - space *${space.alias}* (${space.id}) : ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.updateSpacesQuota.name, msg: `space *${space.alias}* (${space.id}) : ${e}` }))if (space.storageUsage !== spaceQuota.storageUsage) {- this.spacesQueries- .updateSpace(space.id, { storageUsage: spaceQuota.storageUsage })- .then(- (updated: boolean) =>- updated &&- this.logger.log(- `${this.updateSpacesQuota.name} - space *${space.alias}* (${space.id}) - storage usage updated : ${spaceQuota.storageUsage}`- )- )+ this.spacesQueries.updateSpace(space.id, { storageUsage: spaceQuota.storageUsage }).then(+ (updated: boolean) =>+ updated &&+ this.logger.log({+ tag: this.updateSpacesQuota.name,+ msg: `space *${space.alias}* (${space.id}) - storage usage updated : ${spaceQuota.storageUsage}`+ })+ )}if (spaceId) {return spaceQuota@@ -445,9 +443,9 @@ export class SpacesManager {try {await this.sharesManager.deleteAllLinkMembers(space.id, LINK_TYPE.SPACE)await this.deleteOrDisableSpace(space, true)- this.logger.log(`${this.deleteExpiredSpaces.name} - space *${space.alias}* (${space.id}) was deleted`)+ this.logger.log({ tag: this.deleteExpiredSpaces.name, msg: `space *${space.alias}* (${space.id}) was deleted` })} catch (e) {- this.logger.error(`${this.deleteExpiredSpaces.name} - space *${space.alias}* (${space.id}) was not deleted : ${e}`)+ this.logger.error({ tag: this.deleteExpiredSpaces.name, msg: `space *${space.alias}* (${space.id}) was not deleted : ${e}` })}}}@@ -503,9 +501,10 @@ export class SpacesManager {((m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST) && !m.linkId && userIdsWhitelist.indexOf(m.id) === -1) ||((m.type === MEMBER_TYPE.GROUP || m.type === MEMBER_TYPE.PGROUP) && groupIdsWhitelist.indexOf(m.id) === -1)) {- this.logger.warn(- `${this.updateMembers.name} - cannot add ${m.type} (${m.id}) to space *${space.alias}* (${space.id}) : not in the members whitelist`- )+ this.logger.warn({+ tag: this.updateMembers.name,+ msg: `cannot add ${m.type} (${m.id}) to space *${space.alias}* (${space.id}) : not in the members whitelist`+ })return false}return true@@ -515,7 +514,9 @@ export class SpacesManager {// filter linksconst toRemove: SpaceMemberDto[] = remove.filter((m) => !m.linkId)// do remove links- this.sharesManager.deleteLinkMembers(remove.filter((m) => !!m.linkId)).catch((e: Error) => this.logger.error(`${this.updateMembers.name} - ${e}`))+ this.sharesManager+ .deleteLinkMembers(remove.filter((m) => !!m.linkId))+ .catch((e: Error) => this.logger.error({ tag: this.updateMembers.name, msg: `${e}` }))// do update membersconst status: Record<Exclude<ACTION, ACTION.DELETE_PERMANENTLY>,@@ -575,13 +576,13 @@ export class SpacesManager {}}// clear cache &|| notify- this.onSpaceActionForMembers(space, action, members, user).catch((e: Error) => this.logger.error(`${this.updateMembers.name} - ${e}`))+ this.onSpaceActionForMembers(space, action, members, user).catch((e: Error) => this.logger.error({ tag: this.updateMembers.name, msg: `${e}` }))}// do updates// remove or update potential sharesthis.sharesManager.updateSharesFromSpace(space.id, currentMembers, rmShareOwners, upShareOwners)- .catch((e: Error) => this.logger.error(`${this.updateMembers.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.updateMembers.name, msg: `${e}` }))// return potential root owner idsreturn rmRootOwners}@@ -616,7 +617,7 @@ export class SpacesManager {// remove from space cache permissionsthis.spacesQueries.clearCachePermissions(space.alias, [props.alias.old, props.alias.new])- .catch((e: Error) => this.logger.error(`${this.updateRoots.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.updateRoots.name, msg: `${e}` }))// update aliases list for next rootsaliases.push(props.alias.new)}@@ -664,7 +665,7 @@ export class SpacesManager {)Object.entries(status).forEach(([action, roots]: [ACTION, SpaceRootProps[]]) =>this.clearCachePermissionsAndOrNotify(space, action, user, null, roots).catch((e: Error) =>- this.logger.error(`${this.updateRoots.name} - ${e}`)+ this.logger.error({ tag: this.updateRoots.name, msg: `${e}` })))}@@ -680,12 +681,15 @@ export class SpacesManager {const toAdd: SpaceRootProps[] = []for (const r of newRoots) {if (r.externalPath && !user.isAdmin) {- this.logger.warn(`ignore new root *${r.alias}* (${r.externalPath}) : adding an external path requires the admin role`)+ this.logger.warn({+ tag: this.validateNewRoots.name,+ msg: `ignore new root *${r.alias}* (${r.externalPath}) : adding an external path requires the admin role`+ })continue}const rPath = r.externalPath || path.join(user.filesPath, r.file.path)if (!(await isPathExists(rPath))) {- this.logger.warn(`ignore new root *${r.alias}* (${r.file.path}) : *${rPath}* does not exist`)+ this.logger.warn({ tag: this.validateNewRoots.name, msg: `ignore new root *${r.alias}* (${r.file.path}) : *${rPath}* does not exist` })continue}// check if a parent exists for an externalPath or if the file (or parent) is already anchored@@ -698,7 +702,10 @@ export class SpacesManager {)}if (rExists) {- this.logger.warn(`ignore new root *${r.alias}* (${r.externalPath || r.file.path}) (${r.file?.id}) : parent or file already exists in roots`)+ this.logger.warn({+ tag: this.validateNewRoots.name,+ msg: `ignore new root *${r.alias}* (${r.externalPath || r.file.path}) (${r.file?.id}) : parent or file already exists in roots`+ })continue}// keep the file id (maybe already in db)@@ -723,7 +730,7 @@ export class SpacesManager {// clear cache &|| notifyconst memberIds: { groupIds: number[]; userIds: number[] } = await this.spacesQueries.getSpaceMemberIds(space.id)this.onSpaceActionForMembers(space, ACTION.DELETE_PERMANENTLY, memberIds).catch((e: Error) =>- this.logger.error(`${this.deleteOrDisableSpace.name} - ${e}`)+ this.logger.error({ tag: this.deleteOrDisableSpace.name, msg: `${e}` }))// remove all shares related to the spaceawait this.sharesManager.removeSharesFromSpace(space.id)@@ -732,7 +739,7 @@ export class SpacesManager {if (deleteNow) {this.spacesQueries.cache.del(`${CACHE_QUOTA_SPACE_PREFIX}-${space.id}`)- .catch((e: Error) => this.logger.error(`${this.deleteOrDisableSpace.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.deleteOrDisableSpace.name, msg: `${e}` }))await this.deleteSpaceLocation(space.alias)}}@@ -741,9 +748,9 @@ export class SpacesManager {const spaceLocation = SpaceModel.getHomePath(spaceAlias)if (await isPathExists(spaceLocation)) {await removeFiles(spaceLocation)- this.logger.warn(`${this.deleteSpaceLocation.name} - space *${spaceAlias}* location was deleted`)+ this.logger.warn({ tag: this.deleteSpaceLocation.name, msg: `space *${spaceAlias}* location was deleted` })} else {- this.logger.warn(`${this.deleteSpaceLocation.name} - space *${spaceAlias}* location does not exist : ${spaceLocation}`)+ this.logger.warn({ tag: this.deleteSpaceLocation.name, msg: `space *${spaceAlias}* location does not exist : ${spaceLocation}` })}}@@ -752,7 +759,7 @@ export class SpacesManager {if (await isPathExists(currentSpaceLocation)) {const newSpaceLocation: string = SpaceModel.getHomePath(newSpaceAlias)if (await isPathExists(newSpaceLocation)) {- this.logger.warn(`${this.renameSpaceLocation.name} - *${newSpaceAlias}* home path already exists : ${newSpaceLocation}`)+ this.logger.warn({ tag: this.renameSpaceLocation.name, msg: `*${newSpaceAlias}* home path already exists : ${newSpaceLocation}` })return false} else {try {@@ -761,14 +768,15 @@ export class SpacesManager {} catch (e) {// try to restoreawait moveFiles(newSpaceLocation, currentSpaceLocation, true)- this.logger.error(- `${this.renameSpaceLocation.name} - unable to rename space location from *${currentSpaceLocation}* to *${newSpaceLocation}* : ${e}`- )+ this.logger.error({+ tag: this.renameSpaceLocation.name,+ msg: `unable to rename space location from *${currentSpaceLocation}* to *${newSpaceLocation}* : ${e}`+ })return false}}} else {- this.logger.warn(`${this.renameSpaceLocation.name} - *${oldSpaceAlias}* space location does not exist : ${currentSpaceLocation}`)+ this.logger.warn({ tag: this.renameSpaceLocation.name, msg: `*${oldSpaceAlias}* space location does not exist : ${currentSpaceLocation}` })return false}}@@ -795,14 +803,14 @@ export class SpacesManager {// Get all space details if user is a managerconst space: SpaceProps = await this.spacesQueries.getSpaceAsManager(userId, spaceId)if (!space) {- this.logger.warn(`space (${spaceId}) not found or not authorized for user (${userId})`)+ this.logger.warn({ tag: this.userCanAccessSpace.name, msg: `space (${spaceId}) not found or not authorized for user (${userId})` })throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)}return space} else {const [space]: SpaceProps[] = await this.spacesQueries.spaces(userId, true, spaceId)if (!space) {- this.logger.warn(`space (${spaceId}) not found or not authorized for user (${userId})`)+ this.logger.warn({ tag: this.userCanAccessSpace.name, msg: `space (${spaceId}) not found or not authorized for user (${userId})` })throw new HttpException('Space not found', HttpStatus.NOT_FOUND)}return space@@ -811,7 +819,7 @@ export class SpacesManager {private async userIsSpaceManager(user: UserModel, spaceId: number, shareId?: number): Promise<boolean> {if (!(await this.spacesQueries.userIsSpaceManager(user.id, spaceId, shareId))) {- this.logger.warn(`space (${spaceId}) not found or not authorized for user (${user.id})`)+ this.logger.warn({ tag: this.userIsSpaceManager.name, msg: `space (${spaceId}) not found or not authorized for user (${user.id})` })throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)}return true@@ -824,7 +832,7 @@ export class SpacesManager {}const cacheQuotaKey = quotaKeyFromSpace(user.id, space)if (!cacheQuotaKey) {- this.logger.verbose(`${this.setQuotaExceeded.name} - quota was ignored for space : *${space.alias}* (${space.id})`)+ this.logger.verbose({ tag: this.setQuotaExceeded.name, msg: `quota was ignored for space : *${space.alias}* (${space.id})` })return}let quota: StorageQuota = await this.spacesQueries.cache.get(cacheQuotaKey)@@ -844,7 +852,7 @@ export class SpacesManager {space.storageQuota = quota.storageQuotaspace.quotaIsExceeded = quota.storageQuota !== null && quota.storageUsage >= quota.storageQuota} else {- this.logger.verbose(`${this.setQuotaExceeded.name} - quota not found for space : *${space.alias}* (${space.id})`)+ this.logger.verbose({ tag: this.setQuotaExceeded.name, msg: `quota not found for space : *${space.alias}* (${space.id})` })}}@@ -864,7 +872,7 @@ export class SpacesManager {Array.from(new Set([...(await this.usersQueries.allUserIdsFromGroupsAndSubGroups(members.groupIds)), ...members.userIds])).filter((uid) => uid !== user?.id)- ).catch((e: Error) => this.logger.error(`${this.onSpaceActionForMembers.name} - ${e}`))+ ).catch((e: Error) => this.logger.error({ tag: this.onSpaceActionForMembers.name, msg: `${e}` }))}private async clearCachePermissionsAndOrNotify(@@ -877,16 +885,19 @@ export class SpacesManager {if (memberIds?.length) {// clear permissions for space membersif (action === ACTION.DELETE_PERMANENTLY) {- this.logger.verbose(`${this.clearCachePermissionsAndOrNotify.name} - space:${space.alias} ${action}`)+ this.logger.verbose({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `space:${space.alias} ${action}` })this.spacesQueries.clearCachePermissions(space.alias)- .catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `${e}` }))} else {// update space members cache- this.logger.verbose(`${this.clearCachePermissionsAndOrNotify.name} - space:${space.alias} ${action} members:${JSON.stringify(memberIds)}`)+ this.logger.verbose({+ tag: this.clearCachePermissionsAndOrNotify.name,+ msg: `space:${space.alias} ${action} members:${JSON.stringify(memberIds)}`+ })this.spacesQueries.clearCachePermissions(space.alias, undefined, memberIds)- .catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `${e}` }))}// notifyif (action !== ACTION.UPDATE) {@@ -902,16 +913,19 @@ export class SpacesManager {currentUrl: this.contextManager.headerOriginUrl(),action: action})- .catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `${e}` }))}} else if (roots?.length) {// clear permissions for space rootsconst rootAliases: string[] = roots.map((r) => r.alias)- this.logger.verbose(`${this.clearCachePermissionsAndOrNotify.name} - space:${space.alias} ${action} roots:${JSON.stringify(rootAliases)}`)+ this.logger.verbose({+ tag: this.clearCachePermissionsAndOrNotify.name,+ msg: `space:${space.alias} ${action} roots:${JSON.stringify(rootAliases)}`+ })if (action !== ACTION.ADD) {this.spacesQueries.clearCachePermissions(space.alias, rootAliases)- .catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `${e}` }))}// notifyif (action !== ACTION.UPDATE) {@@ -936,7 +950,7 @@ export class SpacesManager {author: user,action: action})- .catch((e: Error) => this.logger.error(`${this.clearCachePermissionsAndOrNotify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearCachePermissionsAndOrNotify.name, msg: `${e}` }))}}}diff --git a/backend/src/applications/spaces/services/spaces-queries.service.ts b/backend/src/applications/spaces/services/spaces-queries.service.tsindex d5b6bc08..ae8bfb23 100644--- a/backend/src/applications/spaces/services/spaces-queries.service.ts+++ b/backend/src/applications/spaces/services/spaces-queries.service.ts@@ -231,10 +231,10 @@ export class SpacesQueries {async updateSpace(id: number, set: Partial<Record<keyof Space, any>>): Promise<boolean> {try {dbCheckAffectedRows(await this.db.update(spaces).set(set).where(eq(spaces.id, id)), 1)- this.logger.debug(`${this.updateSpace.name} - space (${id}) was updated : ${JSON.stringify(set)}`)+ this.logger.debug({ tag: this.updateSpace.name, msg: `space (${id}) was updated : ${JSON.stringify(set)}` })return true} catch (e) {- this.logger.error(`${this.updateSpace.name} - space (${id}) was not updated : ${JSON.stringify(set)} : ${e}`)+ this.logger.error({ tag: this.updateSpace.name, msg: `space (${id}) was not updated : ${JSON.stringify(set)} : ${e}` })return false}}@@ -385,9 +385,9 @@ export class SpacesQueries {1)status[ACTION.ADD][`${m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST ? 'userIds' : 'groupIds'}`].push(m.id)- this.logger.debug(`${this.updateMembers.name} - ${m.type} (${m.id}) added to the space (${spaceId})`)+ this.logger.debug({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) added to the space (${spaceId})` })} catch (e) {- this.logger.error(`${this.updateMembers.name} - ${m.type} (${m.id}) was not added to the space ${spaceId} -> : ${e}`)+ this.logger.error({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) was not added to the space ${spaceId} -> : ${e}` })}}// update@@ -412,9 +412,12 @@ export class SpacesQueries {1)status[ACTION.UPDATE][`${m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST ? 'userIds' : 'groupIds'}`].push(m.id)- this.logger.debug(`${this.updateMembers.name} - ${m.type} (${m.id}) was updated on space (${spaceId}) : ${JSON.stringify(props)}`)+ this.logger.debug({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) was updated on space (${spaceId}) : ${JSON.stringify(props)}` })} catch (e) {- this.logger.error(`${this.updateMembers.name} - ${m.type} (${m.id}) was not updated on space (${spaceId}) : ${JSON.stringify(props)} : ${e}`)+ this.logger.error({+ tag: this.updateMembers.name,+ msg: `${m.type} (${m.id}) was not updated on space (${spaceId}) : ${JSON.stringify(props)} : ${e}`+ })}}// remove@@ -432,9 +435,9 @@ export class SpacesQueries {1)status[ACTION.DELETE][`${m.type === MEMBER_TYPE.USER || m.type === MEMBER_TYPE.GUEST ? 'userIds' : 'groupIds'}`].push(m.id)- this.logger.debug(`${this.updateMembers.name} - ${m.type} (${m.id}) removed from space (${spaceId})`)+ this.logger.debug({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) removed from space (${spaceId})` })} catch (e) {- this.logger.error(`${this.updateMembers.name} - ${m.type} (${m.id}) was not removed from space (${spaceId}) : ${e}`)+ this.logger.error({ tag: this.updateMembers.name, msg: `${m.type} (${m.id}) was not removed from space (${spaceId}) : ${e}` })}}return status@@ -617,10 +620,10 @@ export class SpacesQueries {}try {dbCheckAffectedRows(await this.db.insert(spacesRoots).values(r as SpaceRoot), 1)- this.logger.debug(`${this.addRoot.name} - *${root.alias}* (${root.id}) added`)+ this.logger.debug({ tag: this.addRoot.name, msg: `*${root.alias}* (${root.id}) added` })return true} catch (e) {- this.logger.error(`${this.addRoot.name} - *${root.alias}* (${root.id}) was not added : ${JSON.stringify(root)} : ${e}`)+ this.logger.error({ tag: this.addRoot.name, msg: `*${root.alias}* (${root.id}) was not added : ${JSON.stringify(root)} : ${e}` })return false}}@@ -636,10 +639,10 @@ export class SpacesQueries {.limit(1),1)- this.logger.debug(`${this.updateRoot.name} - ${JSON.stringify(filters)} was updated : ${JSON.stringify(set)}`)+ this.logger.debug({ tag: this.updateRoot.name, msg: `${JSON.stringify(filters)} was updated : ${JSON.stringify(set)}` })return true} catch (e) {- this.logger.error(`${this.updateRoot.name} - ${JSON.stringify(filters)} was not updated : ${JSON.stringify(set)} : ${e}`)+ this.logger.error({ tag: this.updateRoot.name, msg: `${JSON.stringify(filters)} was not updated : ${JSON.stringify(set)} : ${e}` })return false}}@@ -673,8 +676,8 @@ export class SpacesQueries {for (const p of patterns) {const keys = await this.cache.keys(p)if (keys.length) {- this.logger.verbose(`${this.clearCachePermissions.name} - ${JSON.stringify(keys)}`)- this.cache.mdel(keys).catch((e: Error) => this.logger.error(`${this.clearCachePermissions.name} - ${e}`))+ this.logger.verbose({ tag: this.clearCachePermissions.name, msg: `${JSON.stringify(keys)}` })+ this.cache.mdel(keys).catch((e: Error) => this.logger.error({ tag: this.clearCachePermissions.name, msg: `${e}` }))}}}@@ -683,10 +686,10 @@ export class SpacesQueries {private async removeRoot(id: number): Promise<boolean> {try {dbCheckAffectedRows(await this.db.delete(spacesRoots).where(eq(spacesRoots.id, id)), 1)- this.logger.debug(`${this.removeRoot.name} - root (${id}) removed`)+ this.logger.debug({ tag: this.removeRoot.name, msg: `root (${id}) removed` })return true} catch (e) {- this.logger.error(`${this.removeRoot.name} - root (${id}) was not deleted : ${e}`)+ this.logger.error({ tag: this.removeRoot.name, msg: `root (${id}) was not deleted : ${e}` })return false}}diff --git a/backend/src/applications/spaces/services/spaces-scheduler.service.ts b/backend/src/applications/spaces/services/spaces-scheduler.service.tsindex 9ea22e38..f4abaf37 100644--- a/backend/src/applications/spaces/services/spaces-scheduler.service.ts+++ b/backend/src/applications/spaces/services/spaces-scheduler.service.ts@@ -19,38 +19,38 @@ export class SpacesScheduler {@Cron(CronExpression.EVERY_HOUR)async updateQuotas() {- this.logger.log('Update Personal Quotas - START')+ this.logger.log({ tag: this.updateQuotas.name, msg: 'Personals - START' })try {await this.spacesManager.updatePersonalSpacesQuota()} catch (e) {- this.logger.error(`Update Personal Quotas} - ${e}`)+ this.logger.error({ tag: this.updateQuotas.name, msg: `Personals} - ${e}` })}- this.logger.log('Update Personal Quotas - END')- this.logger.log('Update Space Quotas - START')+ this.logger.log({ tag: this.updateQuotas.name, msg: 'Personals - END' })+ this.logger.log({ tag: this.updateQuotas.name, msg: 'Spaces - START' })try {await this.spacesManager.updateSpacesQuota()} catch (e) {- this.logger.error(`Update Space Quotas - ${e}`)+ this.logger.error({ tag: this.updateQuotas.name, msg: `Spaces - ${e}` })}- this.logger.log('Update Space Quotas - END')- this.logger.log('Update Share External Path Quotas - START')+ this.logger.log({ tag: this.updateQuotas.name, msg: 'Spaces - END' })+ this.logger.log({ tag: this.updateQuotas.name, msg: 'Share External Paths - START' })try {await this.sharesManager.updateSharesExternalPathQuota()} catch (e) {- this.logger.error(`Update Share External Path Quotas - ${e}`)+ this.logger.error({ tag: this.updateQuotas.name, msg: `Share External Paths - ${e}` })}- this.logger.log('Update Share External Path Quotas - END')+ this.logger.log({ tag: this.updateQuotas.name, msg: 'Share External Paths - END' })}@Cron(CronExpression.EVERY_DAY_AT_2AM)async deleteExpiredSpaces() {/* Removes spaces that have been disabled for more than 30 days */- this.logger.log(`${this.deleteExpiredSpaces.name} - START`)+ this.logger.log({ tag: this.deleteExpiredSpaces.name, msg: `START` })try {await this.spacesManager.deleteExpiredSpaces()} catch (e) {- this.logger.error(`${this.deleteExpiredSpaces.name} - ${e}`)+ this.logger.error({ tag: this.deleteExpiredSpaces.name, msg: `${e}` })}- this.logger.log(`${this.deleteExpiredSpaces.name} - DONE`)+ this.logger.log({ tag: this.deleteExpiredSpaces.name, msg: `DONE` })}}diff --git a/backend/src/applications/sync/services/sync-clients-manager.service.ts b/backend/src/applications/sync/services/sync-clients-manager.service.tsindex 60d13ece..0bf1e659 100644--- a/backend/src/applications/sync/services/sync-clients-manager.service.ts+++ b/backend/src/applications/sync/services/sync-clients-manager.service.ts@@ -48,26 +48,29 @@ export class SyncClientsManager {async register(clientRegistrationDto: SyncClientRegistrationDto, ip: string): Promise<SyncClientAuthRegistration> {const user: UserModel = await this.authProvider.validateUser(clientRegistrationDto.login, clientRegistrationDto.password, ip, AUTH_SCOPE.CLIENT)if (!user) {- this.logger.warn(`${this.register.name} - auth failed for user *${clientRegistrationDto.login}*`)+ this.logger.warn({ tag: this.register.name, msg: `auth failed for user *${clientRegistrationDto.login}*` })throw new HttpException('Wrong login or password', HttpStatus.UNAUTHORIZED)}if (!user.havePermission(USER_PERMISSION.DESKTOP_APP)) {- this.logger.warn(`${this.register.name} - user *${user.login}* (${user.id}) does not have permission : ${USER_PERMISSION.DESKTOP_APP}`)+ this.logger.warn({+ tag: this.register.name,+ msg: `user *${user.login}* (${user.id}) does not have permission : ${USER_PERMISSION.DESKTOP_APP}`+ })throw new HttpException('Missing permission', HttpStatus.FORBIDDEN)}if (configuration.auth.mfa.totp.enabled && user.twoFaEnabled) {// Checking TOTP code and recovery codeif (!clientRegistrationDto.code) {- this.logger.warn(`${this.register.name} - missing two-fa code for user *${user.login}* (${user.id})`)+ this.logger.warn({ tag: this.register.name, msg: `missing two-fa code for user *${user.login}* (${user.id})` })throw new HttpException('Missing TWO-FA code', HttpStatus.UNAUTHORIZED)}const authCode = this.authProvider2FA.validateTwoFactorCode(clientRegistrationDto.code, user.secrets.twoFaSecret)if (!authCode.success) {- this.logger.warn(`${this.register.name} - two-fa code for *${user.login}* (${user.id}) - ${authCode.message}`)+ this.logger.warn({ tag: this.register.name, msg: `two-fa code for *${user.login}* (${user.id}) - ${authCode.message}` })const authRCode = await this.authProvider2FA.validateRecoveryCode(user.id, clientRegistrationDto.code, user.secrets.recoveryCodes)if (!authRCode.success) {- this.logger.warn(`${this.register.name} - two-fa recovery code for *${user.login}* (${user.id}) - ${authRCode.message}`)- this.usersManager.updateAccesses(user, ip, false).catch((e: Error) => this.logger.error(`${this.register.name} - ${e}`))+ this.logger.warn({ tag: this.register.name, msg: `two-fa recovery code for *${user.login}* (${user.id}) - ${authRCode.message}` })+ this.usersManager.updateAccesses(user, ip, false).catch((e: Error) => this.logger.error({ tag: this.register.name, msg: `${e}` }))throw new HttpException(authCode.message, HttpStatus.UNAUTHORIZED)}}@@ -87,7 +90,7 @@ export class SyncClientsManager {try {await this.syncQueries.deleteClient(user.id, user.clientId)} catch (e) {- this.logger.error(`${this.unregister.name} - ${e}`)+ this.logger.error({ tag: this.unregister.name, msg: `${e}` })throw new HttpException('Error during the removing of client registration', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -108,7 +111,7 @@ export class SyncClientsManager {if (currentTimeStamp() >= client.tokenExpiration) {throw new HttpException(CLIENT_TOKEN_EXPIRED_ERROR, HttpStatus.FORBIDDEN)}- this.syncQueries.updateClientInfo(client, client.info, ip).catch((e: Error) => this.logger.error(`${this.authenticate.name} - ${e}`))+ this.syncQueries.updateClientInfo(client, client.info, ip).catch((e: Error) => this.logger.error({ tag: this.authenticate.name, msg: `${e}` }))const user: UserModel = await this.usersManager.fromUserId(client.ownerId)if (!user) {throw new HttpException('User does not exist', HttpStatus.FORBIDDEN)@@ -117,13 +120,13 @@ export class SyncClientsManager {throw new HttpException('Account suspended or not authorized', HttpStatus.FORBIDDEN)}if (!user.havePermission(USER_PERMISSION.DESKTOP_APP)) {- this.logger.warn(`${this.register.name} - does not have permission : ${USER_PERMISSION.DESKTOP_APP}`)+ this.logger.warn({ tag: this.authenticate.name, msg: `does not have permission : ${USER_PERMISSION.DESKTOP_APP}` })throw new HttpException('Missing permission', HttpStatus.FORBIDDEN)}// set clientIduser.clientId = client.id// update accesses- this.usersManager.updateAccesses(user, ip, true).catch((e: Error) => this.logger.error(`${this.authenticate.name} - ${e}`))+ this.usersManager.updateAccesses(user, ip, true).catch((e: Error) => this.logger.error({ tag: this.authenticate.name, msg: `${e}` }))let r: SyncClientAuthToken | SyncClientAuthCookieif (authType === CLIENT_AUTH_TYPE.COOKIE) {// used by the desktop app to perform the login setup using cookies@@ -148,11 +151,14 @@ export class SyncClientsManager {}const token = crypto.randomUUID()const expiration = currentTimeStamp() + convertHumanTimeToSeconds(CLIENT_TOKEN_EXPIRATION_TIME)- this.logger.log(`${this.renewTokenAndExpiration.name} - renew token for user *${owner.login}* and client *${client.id}*`)+ this.logger.log({ tag: this.renewTokenAndExpiration.name, msg: `renew token for user *${owner.login}* and client *${client.id}*` })try {await this.syncQueries.renewClientTokenAndExpiration(client.id, token, expiration)} catch (e) {- this.logger.error(`${this.renewTokenAndExpiration.name} - unable to renew token for user *${owner.login}* and client *${client.id}* : ${e}`)+ this.logger.error({+ tag: this.renewTokenAndExpiration.name,+ msg: `unable to renew token for user *${owner.login}* and client *${client.id}* : ${e}`+ })throw new HttpException('Unable to update client token', HttpStatus.BAD_REQUEST)}return token@@ -162,7 +168,7 @@ export class SyncClientsManager {try {await this.syncQueries.deleteClient(user.id, clientId)} catch (e) {- this.logger.error(`${this.deleteClient.name} - ${e}`)+ this.logger.error({ tag: this.deleteClient.name, msg: `${e}` })throw new HttpException('Unable to delete client', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -180,12 +186,12 @@ export class SyncClientsManager {manifest = res.datamanifest.repository = APP_STORE_REPOSITORY.PUBLIC} catch (e) {- this.logger.warn(`${this.checkAppStore.name} - unable to retrieve ${url} : ${e}`)+ this.logger.warn({ tag: this.checkAppStore.name, msg: `unable to retrieve ${url} : ${e}` })}} else {const latestFile = path.join(STATIC_PATH, APP_STORE_DIRNAME, APP_STORE_MANIFEST_FILE)if (!(await isPathExists(latestFile))) {- this.logger.warn(`${this.checkAppStore.name} - ${latestFile} does not exist`)+ this.logger.warn({ tag: this.checkAppStore.name, msg: `${latestFile} does not exist` })} else {try {manifest = JSON.parse(await fs.readFile(latestFile, 'utf8'))@@ -201,7 +207,7 @@ export class SyncClientsManager {}}} catch (e) {- this.logger.error(`${this.checkAppStore.name} - ${latestFile} : ${e}`)+ this.logger.error({ tag: this.checkAppStore.name, msg: `${latestFile} : ${e}` })}}}@@ -211,10 +217,10 @@ export class SyncClientsManager {private async getOrCreateClient(user: UserModel, clientId: string, clientInfo: SyncClientInfo, ip: string): Promise<SyncClientAuthRegistration> {try {const token = await this.syncQueries.getOrCreateClient(user.id, clientId, clientInfo, ip)- this.logger.log(`${this.register.name} - client *${clientInfo.type}* was registered for user *${user.login}* (${user.id})`)+ this.logger.log({ tag: this.getOrCreateClient.name, msg: `client *${clientInfo.type}* was registered for user *${user.login}* (${user.id})` })return { clientId: clientId, clientToken: token } satisfies SyncClientAuthRegistration} catch (e) {- this.logger.error(`${this.register.name} - ${e}`)+ this.logger.error({ tag: this.getOrCreateClient.name, msg: `${e}` })throw new HttpException('Error during the client registration', HttpStatus.INTERNAL_SERVER_ERROR)}}diff --git a/backend/src/applications/sync/services/sync-manager.service.ts b/backend/src/applications/sync/services/sync-manager.service.tsindex dfbc226c..c98240b7 100644--- a/backend/src/applications/sync/services/sync-manager.service.ts+++ b/backend/src/applications/sync/services/sync-manager.service.ts@@ -161,7 +161,7 @@ export class SyncManager {}res.raw.write(SYNC_DIFF_DONE)} catch (e) {- this.logger.error(`${this.diff.name} : ${e.message}`)+ this.logger.error({ tag: this.diff.name, msg: `${e.message}` })res.raw.write(`${e.message}\n`)res.status(HttpStatus.INTERNAL_SERVER_ERROR)}@@ -181,7 +181,7 @@ export class SyncManager {for (const entry of await fs.readdir(dir, { withFileTypes: true })) {const realPath = path.join(entry.parentPath, entry.name)if (!entry.isDirectory() && !entry.isFile()) {- this.logger.log(`${this.parseFiles.name} - ignore special file: ${realPath}`)+ this.logger.log({ tag: this.parseFiles.name, msg: `ignore special file: ${realPath}` })continue}if (entry.isDirectory()) {@@ -198,7 +198,7 @@ export class SyncManager {}}} catch (e) {- this.logger.error(`${this.parseFiles.name} - unable to parse directory : ${dir} : ${e}`)+ this.logger.error({ tag: this.parseFiles.name, msg: `unable to parse directory : ${dir} : ${e}` })throw new Error('Unable to parse path')}}@@ -215,12 +215,12 @@ export class SyncManager {try {stats = await fs.stat(realPath)} catch (e) {- this.logger.warn(`${this.analyzeFile.name} - unable to get file stats : ${realPath} : ${e}`)+ this.logger.warn({ tag: this.analyzeFile.name, msg: `unable to get file stats : ${realPath} : ${e}` })return { [filePath]: [F_SPECIAL_STAT.ERROR, e.toString()] }}if (ctx.syncDiff.pathFilters && ctx.syncDiff.pathFilters.test(filePath)) {- this.logger.verbose(`${this.analyzeFile.name} - ignore filtered file : ${realPath}`)+ this.logger.verbose({ tag: this.analyzeFile.name, msg: `ignore filtered file : ${realPath}` })return { [filePath]: [F_SPECIAL_STAT.FILTERED, stats.isDirectory()] }}@@ -235,7 +235,7 @@ export class SyncManager {try {await this.checkSumFile(ctx, filePath, realPath, fileStats)} catch (e) {- this.logger.error(`${this.analyzeFile.name} - file error : ${realPath} - ${e}`)+ this.logger.error({ tag: this.analyzeFile.name, msg: `file error : ${realPath} - ${e}` })return { [filePath]: [F_SPECIAL_STAT.ERROR, e.toString()] }}}@@ -259,7 +259,7 @@ export class SyncManager {}private handleError(space: SpaceEnv, action: string, e: any, dstSpace?: SpaceEnv) {- this.logger.error(`unable to ${action} ${space.url}${dstSpace?.url ? ` -> ${dstSpace.url}` : ''} : ${e}`)+ this.logger.error({ tag: this.handleError.name, msg: `unable to ${action} ${space.url}${dstSpace?.url ? ` -> ${dstSpace.url}` : ''} : ${e}` })// Remove the last part to avoid exposing the pathconst errorMsg = e.message.split(',')[0]if (e instanceof LockConflict) {diff --git a/backend/src/applications/sync/services/sync-paths-manager.service.ts b/backend/src/applications/sync/services/sync-paths-manager.service.tsindex a4bcfd00..da8e421e 100644--- a/backend/src/applications/sync/services/sync-paths-manager.service.ts+++ b/backend/src/applications/sync/services/sync-paths-manager.service.ts@@ -73,7 +73,7 @@ export class SyncPathsManager {try {await this.syncQueries.deletePath(clientId, pathId)} catch (e) {- this.logger.error(`${this.deletePath.name} - ${e}`)+ this.logger.error({ tag: this.deletePath.name, msg: `${e}` })throw new HttpException('Unable to remove path', HttpStatus.BAD_REQUEST)}}@@ -94,7 +94,7 @@ export class SyncPathsManager {try {await this.syncQueries.updatePathSettings(clientId, pathId, syncPathSettings)} catch (e) {- this.logger.error(`${this.updatePath.name} - ${e}`)+ this.logger.error({ tag: this.updatePath.name, msg: `${e}` })throw new HttpException('Unable to update path', HttpStatus.INTERNAL_SERVER_ERROR)} finally {// clear cache@@ -171,7 +171,7 @@ export class SyncPathsManager {if (clientNewer || hasUpdates || serverPath.settings.lastSync !== clientPath.lastSync) {this.syncQueries.updatePathSettings(user.clientId, clientPath.id, { ...updatedSettings, lastSync: clientPath.lastSync })- .catch((e: Error) => this.logger.error(`${this.updatePaths.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.updatePaths.name, msg: `${e}` }))}if (!clientNewer && hasUpdates) {@@ -182,7 +182,7 @@ export class SyncPathsManager {clientDiff.delete = clientPathIds.filter((cid) => serverPathIds.indexOf(cid) === -1)for (const cPathId of clientDiff.delete) {const cPath: SyncPathDto = syncPathsDto.find((p) => p.id === cPathId)- this.notify(user.id, ACTION.DELETE, cPath.remotePath).catch((e: Error) => this.logger.error(`${this.updatePaths.name} - ${e}`))+ this.notify(user.id, ACTION.DELETE, cPath.remotePath).catch((e: Error) => this.logger.error({ tag: this.updatePaths.name, msg: `${e}` }))}// clear cacheclientDiff.update.forEach((path) => this.syncQueries.clearCachePathSettings(user.clientId, path.id))@@ -238,6 +238,6 @@ export class SyncPathsManager {currentUrl: this.contextManager.headerOriginUrl(),action: action})- .catch((e: Error) => this.logger.error(`${this.notify.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.notify.name, msg: `${e}` }))}}diff --git a/backend/src/applications/users/services/admin-users-manager.service.ts b/backend/src/applications/users/services/admin-users-manager.service.tsindex 6ac7e316..92fb6779 100644--- a/backend/src/applications/users/services/admin-users-manager.service.ts+++ b/backend/src/applications/users/services/admin-users-manager.service.ts@@ -58,9 +58,10 @@ export class AdminUsersManager {createUserDto.password = await hashPassword(createUserDto.password)const userId: number = await this.adminQueries.usersQueries.createUserOrGuest(createUserDto, userRole)const user = new UserModel({ ...createUserDto, id: userId, role: userRole })- this.logger.log(- `${this.createUserOrGuest.name} - ${USER_ROLE[userRole]} (${userId}) was created : ${JSON.stringify(anonymizePassword(createUserDto))}`- )+ this.logger.log({+ tag: this.createUserOrGuest.name,+ msg: `${USER_ROLE[userRole]} (${userId}) was created : ${JSON.stringify(anonymizePassword(createUserDto))}`+ })this.adminQueries.usersQueries.clearWhiteListCaches('*')await user.makePaths()if (userRole <= USER_ROLE.USER) {@@ -69,7 +70,7 @@ export class AdminUsersManager {return asAdmin ? this.getGuest(user.id) : user}} catch (e) {- this.logger.error(`${this.createUserOrGuest.name} - unable to create user *${createUserDto.login}* : ${e}`)+ this.logger.error({ tag: this.createUserOrGuest.name, msg: `unable to create user *${createUserDto.login}* : ${e}` })throw new HttpException('Unable to create user', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -166,15 +167,15 @@ export class AdminUsersManager {async deleteUserOrGuest(userId: number, userLogin: string, deleteUserDto: DeleteUserDto): Promise<void> {try {if (await this.adminQueries.deleteUser(userId, userLogin)) {- this.logger.log(`${this.deleteUserOrGuest.name} - *${userLogin}* (${userId}) was deleted`)+ this.logger.log({ tag: this.deleteUserOrGuest.name, msg: `*${userLogin}* (${userId}) was deleted` })} else {- this.logger.error(`${this.deleteUserOrGuest.name} - *${userLogin}* (${userId}) was not deleted : not found`)+ this.logger.error({ tag: this.deleteUserOrGuest.name, msg: `*${userLogin}* (${userId}) was not deleted : not found` })}if (deleteUserDto.deleteSpace) {await this.deleteUserSpace(userLogin, deleteUserDto.isGuest)}} catch (e) {- this.logger.error(`${this.deleteUserOrGuest.name} - unable to delete *${userLogin}* (${userId}) : ${e}`)+ this.logger.error({ tag: this.deleteUserOrGuest.name, msg: `unable to delete *${userLogin}* (${userId}) : ${e}` })throw new HttpException('Unable to delete user', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -232,16 +233,16 @@ export class AdminUsersManager {async createGroup(createGroupDto: CreateOrUpdateGroupDto): Promise<AdminGroup> {if (!createGroupDto.name) {- this.logger.error(`${this.createGroup.name} - missing group name : ${JSON.stringify(createGroupDto)}`)+ this.logger.error({ tag: this.createGroup.name, msg: `missing group name : ${JSON.stringify(createGroupDto)}` })throw new HttpException('Group name is missing', HttpStatus.BAD_REQUEST)}await this.checkGroupNameExists(createGroupDto.name)try {const groupId: number = await this.adminQueries.createGroup(createGroupDto)- this.logger.log(`${this.createGroup.name} - group (${groupId}) was created : ${JSON.stringify(createGroupDto)}`)+ this.logger.log({ tag: this.createGroup.name, msg: `group (${groupId}) was created : ${JSON.stringify(createGroupDto)}` })return this.adminQueries.groupFromId(groupId)} catch (e) {- this.logger.error(`${this.createGroup.name} - group was not created : ${JSON.stringify(createGroupDto)} : ${e}`)+ this.logger.error({ tag: this.createGroup.name, msg: `group was not created : ${JSON.stringify(createGroupDto)} : ${e}` })throw new HttpException('Unable to create group', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -262,9 +263,9 @@ export class AdminUsersManager {async deleteGroup(groupId: number): Promise<void> {if (await this.adminQueries.deleteGroup(groupId)) {- this.logger.log(`${this.deleteGroup.name} - group (${groupId}) was deleted`)+ this.logger.log({ tag: this.deleteGroup.name, msg: `group (${groupId}) was deleted` })} else {- this.logger.warn(`${this.deleteGroup.name} - group (${groupId}) does not exist`)+ this.logger.warn({ tag: this.deleteGroup.name, msg: `group (${groupId}) does not exist` })throw new HttpException('Unable to delete group', HttpStatus.BAD_REQUEST)}}@@ -328,12 +329,12 @@ export class AdminUsersManager {try {if (await isPathExists(userSpace)) {await removeFiles(userSpace)- this.logger.log(`${this.deleteUserSpace.name} - user space *${userLogin}* was deleted`)+ this.logger.log({ tag: this.deleteUserSpace.name, msg: `user space *${userLogin}* was deleted` })} else {- this.logger.warn(`${this.deleteUserSpace.name} - user space *${userLogin}* does not exist : ${userSpace}`)+ this.logger.warn({ tag: this.deleteUserSpace.name, msg: `user space *${userLogin}* does not exist : ${userSpace}` })}} catch (e) {- this.logger.warn(`${this.deleteUserSpace.name} - user space *${userLogin}* (${userSpace}) was not deleted : ${e}`)+ this.logger.warn({ tag: this.deleteUserSpace.name, msg: `user space *${userLogin}* (${userSpace}) was not deleted : ${e}` })throw new HttpException('Unable to delete user space', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -352,12 +353,12 @@ export class AdminUsersManager {private async renameUserSpace(oldLogin: string, newLogin: string): Promise<boolean> {const currentUserSpace: string = UserModel.getHomePath(oldLogin)if (!(await isPathExists(currentUserSpace))) {- this.logger.warn(`${this.renameUserSpace.name} - user space *${oldLogin}* does not exist : ${currentUserSpace}`)+ this.logger.warn({ tag: this.renameUserSpace.name, msg: `user space *${oldLogin}* does not exist : ${currentUserSpace}` })return false}const newUserSpace: string = UserModel.getHomePath(newLogin)if (await isPathExists(newUserSpace)) {- this.logger.warn(`${this.renameUserSpace.name} - user space *${newLogin}* already exists : ${newUserSpace}`)+ this.logger.warn({ tag: this.renameUserSpace.name, msg: `user space *${newLogin}* already exists : ${newUserSpace}` })return false}try {@@ -366,7 +367,7 @@ export class AdminUsersManager {} catch (e) {// try to restoreawait moveFiles(newUserSpace, currentUserSpace, true)- this.logger.error(`${this.renameUserSpace.name} - unable to rename user space from *${currentUserSpace}* to *${newUserSpace}* : ${e}`)+ this.logger.error({ tag: this.renameUserSpace.name, msg: `unable to rename user space from *${currentUserSpace}* to *${newUserSpace}* : ${e}` })return false}}diff --git a/backend/src/applications/users/services/admin-users-queries.service.ts b/backend/src/applications/users/services/admin-users-queries.service.tsindex f461b0f2..bce11ccd 100644--- a/backend/src/applications/users/services/admin-users-queries.service.ts+++ b/backend/src/applications/users/services/admin-users-queries.service.ts@@ -203,10 +203,10 @@ export class AdminUsersQueries {),groups.add.length)- this.logger.log(`${this.updateUserGroups.name} - user (${userId}) groups ${JSON.stringify(groups.add)} was added`)+ this.logger.log({ tag: this.updateUserGroups.name, msg: `user (${userId}) groups ${JSON.stringify(groups.add)} was added` })this.usersQueries.clearWhiteListCaches([userId])} catch (e) {- this.logger.error(`${this.updateUserGroups.name} - user (${userId}) groups ${JSON.stringify(groups.add)} was not added: ${e}`)+ this.logger.error({ tag: this.updateUserGroups.name, msg: `user (${userId}) groups ${JSON.stringify(groups.add)} was not added: ${e}` })throw new Error('User groups was not added')}}@@ -216,10 +216,10 @@ export class AdminUsersQueries {await this.db.delete(usersGroups).where(and(eq(usersGroups.userId, userId), inArray(usersGroups.groupId, groups.delete))),groups.delete.length)- this.logger.log(`${this.updateUserGroups.name} - user (${userId}) groups ${JSON.stringify(groups.delete)} was deleted`)+ this.logger.log({ tag: this.updateUserGroups.name, msg: `user (${userId}) groups ${JSON.stringify(groups.delete)} was deleted` })this.usersQueries.clearWhiteListCaches([userId])} catch (e) {- this.logger.error(`${this.updateUserGroups.name} - user (${userId}) groups ${JSON.stringify(groups.delete)} was not deleted: ${e}`)+ this.logger.error({ tag: this.updateUserGroups.name, msg: `user (${userId}) groups ${JSON.stringify(groups.delete)} was not deleted: ${e}` })throw new Error('User groups was not deleted')}}@@ -232,10 +232,10 @@ export class AdminUsersQueries {async updateGroup(groupId: number, set: Partial<Record<keyof Group, any>>): Promise<boolean> {try {dbCheckAffectedRows(await this.db.update(groups).set(set).where(eq(groups.id, groupId)), 1)- this.logger.log(`${this.updateGroup.name} - group (${groupId}) was updated : ${JSON.stringify(set)}`)+ this.logger.log({ tag: this.updateGroup.name, msg: `group (${groupId}) was updated : ${JSON.stringify(set)}` })return true} catch (e) {- this.logger.error(`${this.updateGroup.name} - group (${groupId}) was not updated : ${JSON.stringify(set)} : ${e}`)+ this.logger.error({ tag: this.updateGroup.name, msg: `group (${groupId}) was not updated : ${JSON.stringify(set)} : ${e}` })return false}}@@ -272,10 +272,10 @@ export class AdminUsersQueries {),userIdsWithRequiredRole.length)- this.logger.log(`${this.addUsersToGroup.name} - users (${userIds}) was added to group (${groupId})`)+ this.logger.log({ tag: this.addUsersToGroup.name, msg: `users (${userIds}) was added to group (${groupId})` })this.usersQueries.clearWhiteListCaches(userIds)} catch (e) {- this.logger.error(`${this.addUsersToGroup.name} - unable to add users (${userIds}) to group (${groupId}) : ${e}`)+ this.logger.error({ tag: this.addUsersToGroup.name, msg: `unable to add users (${userIds}) to group (${groupId}) : ${e}` })throw new Error('Unable to add users to group')}}@@ -290,11 +290,12 @@ export class AdminUsersQueries {.limit(1),1)- this.logger.log(`${this.updateUserFromGroup.name} - user (${userId}) was updated on group (${groupId}) as ${USER_GROUP_ROLE[role]}`)+ this.logger.log({ tag: this.updateUserFromGroup.name, msg: `user (${userId}) was updated on group (${groupId}) as ${USER_GROUP_ROLE[role]}` })} catch (e) {- this.logger.error(- `${this.updateUserFromGroup.name} - user (${userId}) was not updated on group (${groupId}) as ${USER_GROUP_ROLE[role]} : ${e}`- )+ this.logger.error({+ tag: this.updateUserFromGroup.name,+ msg: `user (${userId}) was not updated on group (${groupId}) as ${USER_GROUP_ROLE[role]} : ${e}`+ })throw new Error('Unable to update user from group')}}@@ -308,10 +309,10 @@ export class AdminUsersQueries {.limit(1),1)- this.logger.log(`${this.removeUserFromGroup.name} - user (${userId}) was removed from group (${groupId})`)+ this.logger.log({ tag: this.removeUserFromGroup.name, msg: `user (${userId}) was removed from group (${groupId})` })this.usersQueries.clearWhiteListCaches([userId])} catch (e) {- this.logger.error(`${this.removeUserFromGroup.name} - user (${userId}) or group (${groupId}) does not exist : ${e}`)+ this.logger.error({ tag: this.removeUserFromGroup.name, msg: `user (${userId}) or group (${groupId}) does not exist : ${e}` })throw new Error('Unable to remove user from group')}}@@ -328,9 +329,12 @@ export class AdminUsersQueries {),managers.add.length)- this.logger.log(`${this.updateGuestManagers.name} - guest (${guestId}) managers ${JSON.stringify(managers.add)} was added`)+ this.logger.log({ tag: this.updateGuestManagers.name, msg: `guest (${guestId}) managers ${JSON.stringify(managers.add)} was added` })} catch (e) {- this.logger.error(`${this.updateGuestManagers.name} - guest (${guestId}) managers ${JSON.stringify(managers.add)} was not added: ${e}`)+ this.logger.error({+ tag: this.updateGuestManagers.name,+ msg: `guest (${guestId}) managers ${JSON.stringify(managers.add)} was not added: ${e}`+ })throw new Error('Guest managers was not added')}}@@ -340,9 +344,12 @@ export class AdminUsersQueries {await this.db.delete(usersGuests).where(and(eq(usersGuests.guestId, guestId), inArray(usersGuests.userId, managers.delete))),managers.delete.length)- this.logger.log(`${this.updateGuestManagers.name} - guest (${guestId}) managers ${JSON.stringify(managers.delete)} was deleted`)+ this.logger.log({ tag: this.updateGuestManagers.name, msg: `guest (${guestId}) managers ${JSON.stringify(managers.delete)} was deleted` })} catch (e) {- this.logger.error(`${this.updateGuestManagers.name} - guest (${guestId}) managers ${JSON.stringify(managers.delete)} was not deleted: ${e}`)+ this.logger.error({+ tag: this.updateGuestManagers.name,+ msg: `guest (${guestId}) managers ${JSON.stringify(managers.delete)} was not deleted: ${e}`+ })throw new Error('Guest managers was not deleted')}}diff --git a/backend/src/applications/users/services/users-manager.service.ts b/backend/src/applications/users/services/users-manager.service.tsindex a1fc56d5..ceacc74f 100755--- a/backend/src/applications/users/services/users-manager.service.ts+++ b/backend/src/applications/users/services/users-manager.service.ts@@ -71,23 +71,23 @@ export class UsersManager {if (!authSuccess && scope) {authSuccess = await this.validateAppPassword(user, password, ip, scope)}- this.updateAccesses(user, ip, authSuccess).catch((e: Error) => this.logger.error(`${this.logUser.name} - ${e}`))+ this.updateAccesses(user, ip, authSuccess).catch((e: Error) => this.logger.error({ tag: this.logUser.name, msg: `${e}` }))if (authSuccess) {await user.makePaths()return user}- this.logger.warn(`${this.logUser.name} - bad password for *${user.login}*`)+ this.logger.warn({ tag: this.logUser.name, msg: `bad password for *${user.login}*` })return null}validateUserAccess(user: UserModel, ip: string) {if (user.role === USER_ROLE.LINK) {- this.logger.error(`${this.validateUserAccess.name} - guest link account ${user} is not authorized to login`)+ this.logger.error({ tag: this.validateUserAccess.name, msg: `guest link account ${user} is not authorized to login` })throw new HttpException('Account is not allowed', HttpStatus.FORBIDDEN)}if (!user.isActive || user.passwordAttempts >= USER_MAX_PASSWORD_ATTEMPTS) {- this.updateAccesses(user, ip, false).catch((e: Error) => this.logger.error(`${this.validateUserAccess.name} - ${e}`))- this.logger.error(`${this.validateUserAccess.name} - user account *${user.login}* is locked`)+ this.updateAccesses(user, ip, false).catch((e: Error) => this.logger.error({ tag: this.validateUserAccess.name, msg: `${e}` }))+ this.logger.error({ tag: this.validateUserAccess.name, msg: `user account *${user.login}* is locked` })this.notifyAccountLocked(user, ip)throw new HttpException('Account locked', HttpStatus.FORBIDDEN)}@@ -96,7 +96,7 @@ export class UsersManager {async me(authUser: UserModel): Promise<Omit<LoginResponseDto, 'token'>> {const user = await this.fromUserId(authUser.id)if (!user) {- this.logger.warn(`User *${authUser.login} (${authUser.id}) not found`)+ this.logger.warn({ tag: this.me.name, msg: `User *${authUser.login} (${authUser.id}) not found` })throw new HttpException(`User not found`, HttpStatus.NOT_FOUND)}user.impersonated = !!authUser.impersonatedFromId@@ -150,17 +150,17 @@ export class UsersManager {try {await pipeline(part.file, createWriteStream(dstPath))} catch (e) {- this.logger.error(`${this.updateAvatar.name} - ${e}`)+ this.logger.error({ tag: this.updateAvatar.name, msg: `${e}` })throw new HttpException('Unable to upload avatar', HttpStatus.INTERNAL_SERVER_ERROR)}if (part.file.truncated) {- this.logger.warn(`${this.updateAvatar.name} - image is too large`)+ this.logger.warn({ tag: this.updateAvatar.name, msg: `image is too large` })throw new HttpException('Image is too large (5MB max)', HttpStatus.PAYLOAD_TOO_LARGE)}try {await moveFiles(dstPath, path.join(req.user.homePath, USER_AVATAR_FILE_NAME), true)} catch (e) {- this.logger.error(`${this.updateAvatar.name} - ${e}`)+ this.logger.error({ tag: this.updateAvatar.name, msg: `${e}` })throw new HttpException('Unable to create avatar', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -214,7 +214,7 @@ export class UsersManager {try {await pipeline(avatarStream, avatarFile)} catch (e) {- this.logger.error(`${this.updateAvatar.name} - ${e}`)+ this.logger.error({ tag: this.getAvatar.name, msg: `${e}` })throw new HttpException('Unable to create avatar', HttpStatus.INTERNAL_SERVER_ERROR)}if (generateIsNotExists) {@@ -285,7 +285,7 @@ export class UsersManager {// update accessesthis.usersQueries.updateUserOrGuest(user.id, { secrets: secrets })- .catch((e: Error) => this.logger.error(`${this.validateAppPassword.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.validateAppPassword.name, msg: `${e}` }))return true}}@@ -293,7 +293,7 @@ export class UsersManager {}setOnlineStatus(user: JwtIdentityPayload, onlineStatus: USER_ONLINE_STATUS) {- this.usersQueries.setOnlineStatus(user.id, onlineStatus).catch((e: Error) => this.logger.error(`${this.setOnlineStatus.name} - ${e}`))+ this.usersQueries.setOnlineStatus(user.id, onlineStatus).catch((e: Error) => this.logger.error({ tag: this.setOnlineStatus.name, msg: `${e}` }))}getOnlineUsers(userIds: number[]): Promise<UserOnline[]> {@@ -329,7 +329,7 @@ export class UsersManager {async createPersonalGroup(user: UserModel, userCreateOrUpdateGroupDto: UserCreateOrUpdateGroupDto): Promise<GroupMember> {if (!userCreateOrUpdateGroupDto.name) {- this.logger.error(`${this.createPersonalGroup.name} - missing group name : ${JSON.stringify(userCreateOrUpdateGroupDto)}`)+ this.logger.error({ tag: this.createPersonalGroup.name, msg: `missing group name : ${JSON.stringify(userCreateOrUpdateGroupDto)}` })throw new HttpException('Group name is missing', HttpStatus.BAD_REQUEST)}if (await this.usersQueries.checkGroupNameExists(userCreateOrUpdateGroupDto.name)) {@@ -337,12 +337,12 @@ export class UsersManager {}try {const groupId: number = await this.usersQueries.createPersonalGroup(user.id, userCreateOrUpdateGroupDto)- this.logger.log(`${this.createPersonalGroup.name} - group (${groupId}) was created : ${JSON.stringify(userCreateOrUpdateGroupDto)}`)+ this.logger.log({ tag: this.createPersonalGroup.name, msg: `group (${groupId}) was created : ${JSON.stringify(userCreateOrUpdateGroupDto)}` })// clear user whiteliststhis.usersQueries.clearWhiteListCaches([user.id])return this.getGroup(user, groupId, false)} catch (e) {- this.logger.error(`${this.createPersonalGroup.name} - group was not created : ${JSON.stringify(userCreateOrUpdateGroupDto)} : ${e}`)+ this.logger.error({ tag: this.createPersonalGroup.name, msg: `group was not created : ${JSON.stringify(userCreateOrUpdateGroupDto)} : ${e}` })throw new HttpException('Unable to create group', HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -434,9 +434,9 @@ export class UsersManager {}try {await this.usersQueries.updateGroupMembers(groupId, { remove: [user.id] })- this.logger.log(`${this.leavePersonalGroup.name} - user (${user.id}) has left group (${groupId})`)+ this.logger.log({ tag: this.leavePersonalGroup.name, msg: `user (${user.id}) has left group (${groupId})` })} catch (e) {- this.logger.error(`${this.leavePersonalGroup.name} - user (${user.id}) has not left group (${groupId}) : ${e}`)+ this.logger.error({ tag: this.leavePersonalGroup.name, msg: `user (${user.id}) has not left group (${groupId}) : ${e}` })throw new HttpException(e.message, HttpStatus.INTERNAL_SERVER_ERROR)}}@@ -446,9 +446,9 @@ export class UsersManager {throw new HttpException('You are not allowed to do this action', HttpStatus.FORBIDDEN)}if (await this.usersQueries.deletePersonalGroup(groupId)) {- this.logger.log(`${this.deletePersonalGroup.name} - group (${groupId}) was deleted`)+ this.logger.log({ tag: this.deletePersonalGroup.name, msg: `group (${groupId}) was deleted` })} else {- this.logger.warn(`${this.deletePersonalGroup.name} - group (${groupId}) does not exist`)+ this.logger.warn({ tag: this.deletePersonalGroup.name, msg: `group (${groupId}) does not exist` })throw new HttpException('Unable to delete group', HttpStatus.BAD_REQUEST)}}@@ -516,6 +516,6 @@ export class UsersManager {element: null,url: ip})- .catch((e: Error) => this.logger.error(`${this.validateUserAccess.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.notifyAccountLocked.name, msg: `${e}` }))}}diff --git a/backend/src/applications/users/services/users-queries.service.ts b/backend/src/applications/users/services/users-queries.service.tsindex 9f5c19d6..f58ff8e4 100644--- a/backend/src/applications/users/services/users-queries.service.ts+++ b/backend/src/applications/users/services/users-queries.service.ts@@ -166,10 +166,13 @@ export class UsersQueries {.where(eq(users.id, userId)),1)- this.logger.verbose(`${this.updateUserOrGuest.name} - user (${userId}) was updated : ${JSON.stringify(anonymizePassword(set))}`)+ this.logger.verbose({ tag: this.updateUserOrGuest.name, msg: `user (${userId}) was updated : ${JSON.stringify(anonymizePassword(set))}` })return true} catch (e) {- this.logger.error(`${this.updateUserOrGuest.name} - user (${userId}) was not updated : ${JSON.stringify(anonymizePassword(set))} : ${e}`)+ this.logger.error({+ tag: this.updateUserOrGuest.name,+ msg: `user (${userId}) was not updated : ${JSON.stringify(anonymizePassword(set))} : ${e}`+ })return false}}@@ -359,9 +362,9 @@ export class UsersQueries {if (Object.keys(set).length) {try {await this.db.update(groups).set(set).where(eq(groups.id, groupId))- this.logger.log(`${this.updateGroup.name} - group (${groupId}) was updated : ${JSON.stringify(set)}`)+ this.logger.log({ tag: this.updateGroup.name, msg: `group (${groupId}) was updated : ${JSON.stringify(set)}` })} catch (e) {- this.logger.error(`${this.updateGroup.name} - group (${groupId}) was not updated : ${JSON.stringify(set)} : ${e}`)+ this.logger.error({ tag: this.updateGroup.name, msg: `group (${groupId}) was not updated : ${JSON.stringify(set)} : ${e}` })throw new Error('Group was not updated')}}@@ -379,11 +382,15 @@ export class UsersQueries {await this.db.insert(usersGroups).values(members.add.map((m) => ({ userId: m.id, groupId: groupId, role: m.groupRole })))// clear cachethis.clearWhiteListCaches(members.add.map((m) => m.id))- this.logger.log(`${this.updateGroupMembers.name} - users ${JSON.stringify(members.add.map((m) => m.id))} was added to group (${groupId})`)+ this.logger.log({+ tag: this.updateGroupMembers.name,+ msg: `users ${JSON.stringify(members.add.map((m) => m.id))} was added to group (${groupId})`+ })} catch (e) {- this.logger.error(- `${this.updateGroupMembers.name} - users ${JSON.stringify(members.add.map((m) => m.id))} was not added to group (${groupId}) : ${e}`- )+ this.logger.error({+ tag: this.updateGroupMembers.name,+ msg: `users ${JSON.stringify(members.add.map((m) => m.id))} was not added to group (${groupId}) : ${e}`+ })throw new Error('Group members was not added')}}@@ -395,9 +402,12 @@ export class UsersQueries {.limit(members.remove.length)// clear cachethis.clearWhiteListCaches(members.remove)- this.logger.log(`${this.updateGroupMembers.name} - users ${JSON.stringify(members.remove)} was removed from group (${groupId})`)+ this.logger.log({ tag: this.updateGroupMembers.name, msg: `users ${JSON.stringify(members.remove)} was removed from group (${groupId})` })} catch (e) {- this.logger.error(`${this.updateGroupMembers.name} - users ${JSON.stringify(members.remove)} was not removed from group (${groupId}) : ${e}`)+ this.logger.error({+ tag: this.updateGroupMembers.name,+ msg: `users ${JSON.stringify(members.remove)} was not removed from group (${groupId}) : ${e}`+ })throw new Error('Group members was not removed')}}@@ -555,10 +565,10 @@ export class UsersQueries {.keys(pattern).then((keys: string[]) => {if (!keys.length) return- this.logger.verbose(`${this.clearWhiteListCaches.name} - ${JSON.stringify(keys)}`)- this.cache.mdel(keys).catch((e: Error) => this.logger.error(`${this.clearWhiteListCaches.name} - ${e}`))+ this.logger.verbose({ tag: this.clearWhiteListCaches.name, msg: `${JSON.stringify(keys)}` })+ this.cache.mdel(keys).catch((e: Error) => this.logger.error({ tag: this.clearWhiteListCaches.name, msg: `${e}` }))})- .catch((e: Error) => this.logger.error(`${this.clearWhiteListCaches.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearWhiteListCaches.name, msg: `${e}` }))}} else {this.cache@@ -566,7 +576,7 @@ export class UsersQueries {...userIds.map((id: number) => this.cache.genSlugKey(this.constructor.name, this.usersWhitelist.name, id)),...userIds.map((id: number) => this.cache.genSlugKey(this.constructor.name, this.groupsWhitelist.name, id))])- .catch((e: Error) => this.logger.error(`${this.clearWhiteListCaches.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.clearWhiteListCaches.name, msg: `${e}` }))}}diff --git a/backend/src/applications/users/users.gateway.ts b/backend/src/applications/users/users.gateway.tsindex bd5deff2..e3e3e0c6 100644--- a/backend/src/applications/users/users.gateway.ts+++ b/backend/src/applications/users/users.gateway.ts@@ -44,21 +44,23 @@ export class WebSocketUsers implements BeforeApplicationShutdown, OnGatewayInit,if (this.shuttingDown) returnsocket.join(`${USER_ROOM_PREFIX}${socket.user.id}`)this.sendOnlineUser(socket.user, parseInt((socket.handshake.query.onlineStatus as string) || '0')).catch((e: Error) =>- this.logger.error(`${this.handleConnection.name} - ${e}`)- )- this.sendAllOnlineUsers(socket.user.id).catch((e: Error) => this.logger.error(`${this.handleConnection.name} - ${e}`))- this.logger.log(- `Connected: *${socket.user.login}* (${socket.user.id}) [${socket.id}] ${getClientAddress(socket)} ${socket.handshake.headers['user-agent']}`+ this.logger.error({ tag: this.handleConnection.name, msg: `${e}` }))+ this.sendAllOnlineUsers(socket.user.id).catch((e: Error) => this.logger.error({ tag: this.handleConnection.name, msg: `${e}` }))+ this.logger.log({+ tag: this.handleConnection.name,+ msg: `Connected: *${socket.user.login}* (${socket.user.id}) [${socket.id}] ${getClientAddress(socket)} ${socket.handshake.headers['user-agent']}`+ })}async handleDisconnect(socket: AuthenticatedSocketIO): Promise<void> {if (this.shuttingDown) returnsocket.leave(`${USER_ROOM_PREFIX}${socket.user.id}`)- this.sendOfflineUser(socket.user.id).catch((e: Error) => this.logger.error(`${this.handleDisconnect.name} - ${e}`))- this.logger.log(- `Disconnected: *${socket.user.login}* (${socket.user.id}) [${socket.id}] ${getClientAddress(socket)} ${socket.handshake.headers['user-agent']}`- )+ this.sendOfflineUser(socket.user.id).catch((e: Error) => this.logger.error({ tag: this.handleDisconnect.name, msg: `${e}` }))+ this.logger.log({+ tag: this.handleDisconnect.name,+ msg: `Disconnected: *${socket.user.login}* (${socket.user.id}) [${socket.id}] ${getClientAddress(socket)} ${socket.handshake.headers['user-agent']}`+ })}@SubscribeMessage(USERS_WS.EVENTS.ONLINE_STATUS)@@ -67,7 +69,7 @@ export class WebSocketUsers implements BeforeApplicationShutdown, OnGatewayInit,// store in dbthis.usersManager.setOnlineStatus(user, body.status)}- this.sendOnlineStatus(user.id, body.status).catch((e: Error) => this.logger.error(`${this.setOnlineStatus.name} - ${e}`))+ this.sendOnlineStatus(user.id, body.status).catch((e: Error) => this.logger.error({ tag: this.setOnlineStatus.name, msg: `${e}` }))}private sendMessageToUsers(userIds: number[], eventName: string, body: any) {@@ -103,7 +105,9 @@ export class WebSocketUsers implements BeforeApplicationShutdown, OnGatewayInit,await sleep(this.waitTime)// check if user room is empty before send eventif ((await this.getOnlineUserIds()).indexOf(userId) === -1) {- this.sendOnlineStatus(userId, USER_ONLINE_STATUS.OFFLINE).catch((e: Error) => this.logger.error(`${this.sendOfflineUser.name} - ${e}`))+ this.sendOnlineStatus(userId, USER_ONLINE_STATUS.OFFLINE).catch((e: Error) =>+ this.logger.error({ tag: this.sendOfflineUser.name, msg: `${e}` })+ )}}diff --git a/backend/src/applications/webdav/guards/webdav-protocol.guard.ts b/backend/src/applications/webdav/guards/webdav-protocol.guard.tsindex 5ee0b56c..9d887519 100644--- a/backend/src/applications/webdav/guards/webdav-protocol.guard.ts+++ b/backend/src/applications/webdav/guards/webdav-protocol.guard.ts@@ -61,7 +61,7 @@ export class WebDAVProtocolGuard implements CanActivate {private checkUserPermission(req: FastifyDAVRequest) {if (req.method !== HTTP_METHOD.OPTIONS && !req.user.havePermission(USER_PERMISSION.WEBDAV)) {- this.logger.warn(`does not have permission : ${USER_PERMISSION.WEBDAV}`)+ this.logger.warn({ tag: this.checkUserPermission.name, msg: `does not have permission : ${USER_PERMISSION.WEBDAV}` })throw new HttpException('Missing permission', HttpStatus.FORBIDDEN)}}@@ -95,9 +95,9 @@ export class WebDAVProtocolGuard implements CanActivate {private parseIfHeader(req: FastifyDAVRequest) {// stores if headers, examine it laterif (req.headers[HEADER.IF]) {- this.logger.verbose(`If header before : ${JSON.stringify(req.headers[HEADER.IF])}`)+ this.logger.verbose({ tag: this.parseIfHeader.name, msg: `If header before : ${JSON.stringify(req.headers[HEADER.IF])}` })const ifHeaders: IfHeader[] = parseIfHeader(req.headers[HEADER.IF] as string)- this.logger.verbose(`If header after : ${JSON.stringify(ifHeaders)}`)+ this.logger.verbose({ tag: this.parseIfHeader.name, msg: `If header after : ${JSON.stringify(ifHeaders)}` })if (ifHeaders.length) req.dav.ifHeaders = ifHeaders}}@@ -106,11 +106,11 @@ export class WebDAVProtocolGuard implements CanActivate {req.dav.depth = (req.headers[HEADER.DEPTH] as string | undefined)?.toLowerCase()if (!req.dav.depth || (req.dav.depth !== DEPTH.MEMBERS && req.dav.depth !== DEPTH.RESOURCE)) {if (!req.dav.depth) {- this.logger.warn('Missing propfind depth, default value 1 was set')+ this.logger.warn({ tag: this.propfindMethod.name, msg: 'Missing propfind depth, default value 1 was set' })} else if (req.dav.depth === DEPTH.INFINITY) {- this.logger.warn('Infinite depth is disabled for security reasons, default value 1 was set')+ this.logger.warn({ tag: this.propfindMethod.name, msg: 'Infinite depth is disabled for security reasons, default value 1 was set' })} else {- this.logger.warn(`Invalid propfind depth header : ${req.dav.depth}, default value 1 was set`)+ this.logger.warn({ tag: this.propfindMethod.name, msg: `Invalid propfind depth header : ${req.dav.depth}, default value 1 was set` })}req.dav.depth = DEPTH.MEMBERS}@@ -123,7 +123,7 @@ export class WebDAVProtocolGuard implements CanActivate {}}if (!req.dav.propfindMode) {- this.logger.warn(`Invalid propfind mode : ${JSON.stringify(Object.keys(req.dav.body.propfind))}`)+ this.logger.warn({ tag: this.propfindMethod.name, msg: `Invalid propfind mode : ${JSON.stringify(Object.keys(req.dav.body.propfind))}` })throw new HttpException('Invalid propfind mode', HttpStatus.BAD_REQUEST)}} else {@@ -140,7 +140,7 @@ export class WebDAVProtocolGuard implements CanActivate {req.dav.depth = ((req.headers[HEADER.DEPTH] as any) || DEPTH.RESOURCE).toLowerCase()this.parseBody(req)if (!req.dav.body || Object.keys(req.dav.body).indexOf(PROPPATCH_PROP_UPDATE) === -1) {- this.logger.debug(`'${PROPPATCH_PROP_UPDATE}' is missing : ${JSON.stringify(req.dav.body)}`)+ this.logger.debug({ tag: this.proppatchMethod.name, msg: `'${PROPPATCH_PROP_UPDATE}' is missing : ${JSON.stringify(req.dav.body)}` })throw new HttpException(`'${PROPPATCH_PROP_UPDATE}' is missing`, HttpStatus.BAD_REQUEST)}this.parseIfHeader(req)@@ -160,7 +160,7 @@ export class WebDAVProtocolGuard implements CanActivate {const seconds = parseInt(timeoutSplit[timeoutSplit.length - 1], 10)req.dav.lock.timeout = seconds > CACHE_LOCK_DEFAULT_TTL ? CACHE_LOCK_DEFAULT_TTL : seconds} catch (e) {- this.logger.warn(`${this.lockMethod.name} - unable to set timeout, use the default value : ${e}`)+ this.logger.warn({ tag: this.lockMethod.name, msg: `unable to set timeout, use the default value : ${e}` })req.dav.lock.timeout = CACHE_LOCK_DEFAULT_TTL}}@@ -168,17 +168,17 @@ export class WebDAVProtocolGuard implements CanActivate {this.parseBody(req)if (req.dav.body) {if (!req.dav.body.lockinfo) {- this.logger.warn(`Missing lockinfo : ${JSON.stringify(req.dav.body)}`)+ this.logger.warn({ tag: this.lockMethod.name, msg: `Missing lockinfo : ${JSON.stringify(req.dav.body)}` })throw new HttpException('Missing lockinfo', HttpStatus.BAD_REQUEST)}try {req.dav.lock.lockscope = Object.keys(req.dav.body.lockinfo.lockscope)[0] as LOCK_SCOPE} catch (e) {- this.logger.warn(`${this.parseBody.name} - invalid or undefined lockscope : ${JSON.stringify(req.dav.body.lockinfo)} : ${e}`)+ this.logger.warn({ tag: this.lockMethod.name, msg: `invalid or undefined lockscope : ${JSON.stringify(req.dav.body.lockinfo)} : ${e}` })throw new HttpException('Invalid or undefined lockscope', HttpStatus.BAD_REQUEST)}if (Object.values(LOCK_SCOPE).indexOf(req.dav.lock.lockscope) === -1) {- this.logger.warn(`${this.parseBody.name} - invalid or undefined lockscope : ${JSON.stringify(req.dav.body.lockinfo)}`)+ this.logger.warn({ tag: this.lockMethod.name, msg: `invalid or undefined lockscope : ${JSON.stringify(req.dav.body.lockinfo)}` })throw new HttpException('Invalid or undefined lockscope', HttpStatus.BAD_REQUEST)}if (req.dav.body.lockinfo.owner) {@@ -232,7 +232,7 @@ export class WebDAVProtocolGuard implements CanActivate {}const destination = urlToPath(req.headers[HEADER.DESTINATION] as string)if (!REGEX_BASE_PATH.test(destination)) {- this.logger.warn(`The destination does not match the webdav base path : ${destination}`)+ this.logger.warn({ tag: this.copyMoveMethod.name, msg: `The destination does not match the webdav base path : ${destination}` })throw new HttpException('The destination does not match', HttpStatus.BAD_REQUEST)}req.dav.depth = ((req.headers[HEADER.DEPTH] as any) || DEPTH.INFINITY).toLowerCase()diff --git a/backend/src/applications/webdav/services/webdav-methods.service.ts b/backend/src/applications/webdav/services/webdav-methods.service.tsindex 2856d142..cc6b8f64 100644--- a/backend/src/applications/webdav/services/webdav-methods.service.ts+++ b/backend/src/applications/webdav/services/webdav-methods.service.ts@@ -64,7 +64,7 @@ export class WebDAVMethods {return this.handleError(req, res, e)}}- this.logger.warn(`Not allowed on this resource : ${repository}`)+ this.logger.warn({ tag: this.headOrGet.name, msg: `Not allowed on this resource : ${repository}` })return res.status(HttpStatus.FORBIDDEN).send('Not allowed on this resource')}@@ -76,14 +76,17 @@ export class WebDAVMethods {if (isLockRefresh) {// if the body has no content, the request must refresh the lockif (!rExists) {- this.logger.warn('Lock refresh must specify an existing resource')+ this.logger.warn({ tag: this.lock.name, msg: 'Lock refresh must specify an existing resource' })return res.status(HttpStatus.BAD_REQUEST).send('Lock refresh must specify an existing resource')}return this.lockRefresh(req, res, req.space.dbFile.path)}if (!rExists) {if (!haveSpaceEnvPermissions(req.space, SPACE_OPERATION.ADD)) {- this.logger.warn(`is not allowed to create on this space : *${req.space.alias}* (${req.space.id}) : ${req.space.url}`)+ this.logger.warn({+ tag: this.lock.name,+ msg: `is not allowed to create on this space : *${req.space.alias}* (${req.space.id}) : ${req.space.url}`+ })return res.status(HttpStatus.FORBIDDEN).send('You are not allowed to do this action')}if (!(await isPathExists(dirName(req.space.realPath)))) {@@ -129,13 +132,13 @@ export class WebDAVMethods {@IfHeaderDecorator()async unlock(req: FastifyDAVRequest, res: FastifyReply) {if (!(await isPathExists(req.space.realPath))) {- this.logger.warn(`Unable to unlock: ${req.dav.url} - resource does not exist`)+ this.logger.warn({ tag: this.unlock.name, msg: `Unable to unlock: ${req.dav.url} - resource does not exist` })return res.status(HttpStatus.NOT_FOUND).send(req.dav.url)}const lock = await this.filesLockManager.isLockedWithToken(req.dav.lock.token, req.space.dbFile.path)if (!lock) {- this.logger.warn(`Lock token does not exist or not match URL : ${req.dav.lock.token}`)+ this.logger.warn({ tag: this.unlock.name, msg: `Lock token does not exist or not match URL : ${req.dav.lock.token}` })return DAV_ERROR_RES(HttpStatus.CONFLICT, PRECONDITION.LOCK_TOKEN_MISMATCH, res)}if (req.user.id !== lock.owner.id) {@@ -261,7 +264,7 @@ export class WebDAVMethods {for (const action of Object.keys(req.dav.body[PROPPATCH_PROP_UPDATE])) {if (Object.values(PROPPATCH_METHOD).indexOf(action) === -1) {const msg = `Unknown tag : expected ${PROPPATCH_METHOD.SET} or ${PROPPATCH_METHOD.REMOVE}`- this.logger.debug(msg)+ this.logger.debug({ tag: this.proppatch.name, msg: msg })return res.status(HttpStatus.BAD_REQUEST).send(msg)}@@ -275,7 +278,7 @@ export class WebDAVMethods {if (Object.keys(req.dav.body[PROPPATCH_PROP_UPDATE][action])[0] !== PROPSTAT.PROP) {const msg = `Unknown tag : expected ${PROPSTAT.PROP}`- this.logger.debug(msg)+ this.logger.debug({ tag: this.proppatch.name, msg: msg })return res.status(HttpStatus.BAD_REQUEST).send(msg)}@@ -287,7 +290,7 @@ export class WebDAVMethods {for (let [name, value] of Object.entries(prop)) {if (action === PROPPATCH_METHOD.REMOVE) {value = null- this.logger.debug(`Proppatch remove method not handled : ${name} -> ${value}`)+ this.logger.debug({ tag: this.proppatch.name, msg: `Proppatch remove method not handled : ${name} -> ${value}` })}if (PROPPATCH_SUPPORTED_PROPS.indexOf(name) === -1) {req.dav.proppatch.errors.push(@@ -322,7 +325,7 @@ export class WebDAVMethods {try {await this.filesManager.touch(req.user, req.space, currentTimeStamp(new Date(value)), false)} catch (e) {- this.logger.error(`${this.proppatch.name} - unable to modify mtime on ${req.dav.url} : ${e}`)+ this.logger.error({ tag: this.proppatch.name, msg: `unable to modify mtime on ${req.dav.url} : ${e}` })states[name] = falseatLeastOneError = true}@@ -359,7 +362,7 @@ export class WebDAVMethods {async copyMove(req: FastifyDAVRequest, res: FastifyReply) {const dstSpace: SpaceEnv = await this.webDAVHandler.spaceEnv(req.user, req.dav.copyMove.destination)if (!dstSpace) {- this.logger.warn(`Space not found for destination : ${req.dav.copyMove.destination}`)+ this.logger.warn({ tag: this.copyMove.name, msg: `Space not found for destination : ${req.dav.copyMove.destination}` })return res.status(HttpStatus.NOT_FOUND).send(req.dav.copyMove.destination)}const dstExisted = await isPathExists(dstSpace.realPath)@@ -401,7 +404,7 @@ export class WebDAVMethods {}// the path will be the same across conditionsif (!lastSpaceEnv) {- this.logger.warn(`If Header : path mismatch (${condition.path})`)+ this.logger.warn({ tag: this.evaluateIfHeaders.name, msg: `If Header : path mismatch (${condition.path})` })return false}} else {@@ -455,7 +458,7 @@ export class WebDAVMethods {}if (!atLeastOneOk) {- this.logger.warn(`If header condition failed : ${errors.join(', ')}`)+ this.logger.warn({ tag: this.evaluateIfHeaders.name, msg: `If header condition failed : ${errors.join(', ')}` })res.status(HttpStatus.PRECONDITION_FAILED).send('If header condition failed')}return atLeastOneOk@@ -463,7 +466,7 @@ export class WebDAVMethods {private async lockRefresh(req: FastifyDAVRequest, res: FastifyReply, dbFilePath: string) {if (req.dav?.ifHeaders?.length !== 1) {- this.logger.warn('Expected a lock token (only one lock may be refreshed at a time)')+ this.logger.warn({ tag: this.lockRefresh.name, msg: 'Expected a lock token (only one lock may be refreshed at a time)' })return res.status(HttpStatus.BAD_REQUEST).send('Expected a lock token (only one lock may be refreshed at a time)')}@@ -471,17 +474,17 @@ export class WebDAVMethods {try {token = extractOneToken(req.dav.ifHeaders)} catch (e) {- this.logger.warn(`${this.lockRefresh.name} - unable to extract token : ${JSON.stringify(req.dav.ifHeaders)} (${e})`)+ this.logger.warn({ tag: this.lockRefresh.name, msg: `unable to extract token : ${JSON.stringify(req.dav.ifHeaders)} (${e})` })return res.status(HttpStatus.BAD_REQUEST).send('Unable to extract token')}const lock = await this.filesLockManager.isLockedWithToken(token, dbFilePath)if (!lock) {- this.logger.warn(`Lock token does not exist or not match URL : ${token}`)+ this.logger.warn({ tag: this.lockRefresh.name, msg: `Lock token does not exist or not match URL : ${token}` })return DAV_ERROR_RES(HttpStatus.PRECONDITION_FAILED, PRECONDITION.LOCK_TOKEN_MISMATCH, res)}if (lock.owner.id !== req.user.id) {- this.logger.warn(`Lock token does not match owner : ${lock.owner.login} != ${req.user.login}`)+ this.logger.warn({ tag: this.lockRefresh.name, msg: `Lock token does not match owner : ${lock.owner.login} != ${req.user.login}` })return res.status(HttpStatus.FORBIDDEN).send('Lock token does not match owner')}@@ -491,7 +494,7 @@ export class WebDAVMethods {}private handleError(req: FastifyDAVRequest, res: FastifyReply, e: any, toUrl?: string) {- this.logger.error(`Unable to ${req.method} ${req.dav.url}${toUrl ? ` -> ${toUrl}` : ''} : ${e.message}`)+ this.logger.error({ tag: this.handleError.name, msg: `Unable to ${req.method} ${req.dav.url}${toUrl ? ` -> ${toUrl}` : ''} : ${e.message}` })// Remove the last part to avoid exposing the pathconst errorMsg = e.message.split(',')[0]if (e instanceof LockConflict) {diff --git a/backend/src/applications/webdav/services/webdav-spaces.service.ts b/backend/src/applications/webdav/services/webdav-spaces.service.tsindex 1cf52831..dbd72167 100644--- a/backend/src/applications/webdav/services/webdav-spaces.service.ts+++ b/backend/src/applications/webdav/services/webdav-spaces.service.ts@@ -45,11 +45,11 @@ export class WebDAVSpaces {return space}} catch (e) {- this.logger.warn(`${this.spaceEnv.name} : ${e}`)+ this.logger.warn({ tag: this.spaceEnv.name, msg: `${e}` })return null}- this.logger.warn(`Space not authorized or not found : ${path}`)+ this.logger.warn({ tag: this.spaceEnv.name, msg: `Space not authorized or not found : ${path}` })return null}@@ -66,7 +66,7 @@ export class WebDAVSpaces {case WEBDAV_NS.TRASH:return this.listTrashes(req)default:- this.logger.error(`Unknown space ${space}`)+ this.logger.error({ tag: this.propfind.name, msg: `Unknown space ${space}` })throw new HttpException('Unknown space', HttpStatus.NOT_FOUND)}}@@ -148,7 +148,7 @@ export class WebDAVSpaces {yield this.roots[WEBDAV_NS.SHARES]} else {if (!(await isPathExists(space.realPath))) {- this.logger.warn(`Location not found : ${space.realPath}`)+ this.logger.warn({ tag: this.listFiles.name, msg: `Location not found : ${space.realPath}` })throw new HttpException('Location not found', HttpStatus.NOT_FOUND)}yield new WebDAVFile(await getProps(space.realPath, req.dav.url), req.dav.url, true)diff --git a/backend/src/authentication/auth.service.ts b/backend/src/authentication/auth.service.tsindex d30903b4..7219687a 100755--- a/backend/src/authentication/auth.service.ts+++ b/backend/src/authentication/auth.service.ts@@ -26,7 +26,7 @@ export class AuthManager {async getTokens(user: UserModel, refresh = false): Promise<TokenResponseDto> {const currentTime = currentTimeStamp()if (refresh && user.exp < currentTime) {- this.logger.error(`${this.getTokens.name} - token refresh has incorrect expiration : *${user.login}*`)+ this.logger.error({ tag: this.getTokens.name, msg: `token refresh has incorrect expiration : *${user.login}*` })throw new HttpException('Token has expired', HttpStatus.FORBIDDEN)}const accessExpiration = convertHumanTimeToSeconds(configuration.auth.token.access.expiration)@@ -81,7 +81,7 @@ export class AuthManager {if (user.exp && user.exp > currentTime) {refreshTokenExpiration = user.exp - currentTime} else {- this.logger.error(`${this.refreshCookies.name} - token ${TOKEN_TYPE.REFRESH} has incorrect expiration : *${user.login}*`)+ this.logger.error({ tag: this.refreshCookies.name, msg: `token ${TOKEN_TYPE.REFRESH} has incorrect expiration : *${user.login}*` })throw new HttpException('Token has expired', HttpStatus.FORBIDDEN)}const csrfToken: string = crypto.randomUUID()@@ -120,18 +120,18 @@ export class AuthManager {}if (!jwtPayload.csrf) {- this.logger.warn(`${this.csrfValidation.name} - ${CSRF_ERROR.MISSING_JWT}`)+ this.logger.warn({ tag: this.csrfValidation.name, msg: `${CSRF_ERROR.MISSING_JWT}` })throw new HttpException(CSRF_ERROR.MISSING_JWT, HttpStatus.FORBIDDEN)}if (!req.headers[CSRF_KEY]) {- this.logger.warn(`${this.csrfValidation.name} - ${CSRF_ERROR.MISSING_HEADERS}`)+ this.logger.warn({ tag: this.csrfValidation.name, msg: `${CSRF_ERROR.MISSING_HEADERS}` })throw new HttpException(CSRF_ERROR.MISSING_HEADERS, HttpStatus.FORBIDDEN)}const csrfHeader: UnsignResult = unsign(req.headers[CSRF_KEY] as string, configuration.auth.token.csrf.secret)if (jwtPayload.csrf !== csrfHeader.value) {- this.logger.warn(`${this.csrfValidation.name} - ${CSRF_ERROR.MISMATCH}`)+ this.logger.warn({ tag: this.csrfValidation.name, msg: `${CSRF_ERROR.MISMATCH}` })throw new HttpException(CSRF_ERROR.MISMATCH, HttpStatus.FORBIDDEN)}}diff --git a/backend/src/authentication/guards/auth-basic.strategy.ts b/backend/src/authentication/guards/auth-basic.strategy.tsindex 53b789f9..df920e62 100644--- a/backend/src/authentication/guards/auth-basic.strategy.ts+++ b/backend/src/authentication/guards/auth-basic.strategy.ts@@ -43,7 +43,7 @@ export class AuthBasicStrategy extends PassportStrategy(HttpBasicStrategy, 'basiuserFromDB.removePassword()}const userToCache: Record<string, any> | null = userFromDB ? instanceToPlain(userFromDB, { excludePrefixes: ['_'] }) : null- this.cache.set(authBasicUser, userToCache, this.CACHE_TTL).catch((e: Error) => this.logger.error(`${this.validate.name} - ${e}`))+ this.cache.set(authBasicUser, userToCache, this.CACHE_TTL).catch((e: Error) => this.logger.error({ tag: this.validate.name, msg: `${e}` }))return userFromDB}}diff --git a/backend/src/authentication/providers/ldap/auth-provider-ldap.service.ts b/backend/src/authentication/providers/ldap/auth-provider-ldap.service.tsindex 0df3fe5d..f8bf22e6 100644--- a/backend/src/authentication/providers/ldap/auth-provider-ldap.service.ts+++ b/backend/src/authentication/providers/ldap/auth-provider-ldap.service.ts@@ -41,7 +41,7 @@ export class AuthProviderLDAP implements AuthProvider {return this.usersManager.logUser(user, password, ip, scope)}if (!user.isActive) {- this.logger.error(`${this.validateUser.name} - user *${user.login}* is locked`)+ this.logger.error({ tag: this.validateUser.name, msg: `user *${user.login}* is locked` })throw new HttpException('Account locked', HttpStatus.FORBIDDEN)}}@@ -73,20 +73,23 @@ export class AuthProviderLDAP implements AuthProvider {}if (!entry[this.ldapConfig.attributes.login] || !entry[this.ldapConfig.attributes.email]) {- this.logger.error(`${this.validateUser.name} - required ldap fields are missing :+ this.logger.error({+ tag: this.validateUser.name,+ msg: `required ldap fields are missing :[${this.ldapConfig.attributes.login}, ${this.ldapConfig.attributes.email}] =>- (${JSON.stringify(entry)})`)+ (${JSON.stringify(entry)})`+ })return null}if (!user && !this.ldapConfig.options.autoCreateUser) {- this.logger.warn(`${this.validateUser.name} - User not found and autoCreateUser is disabled`)+ this.logger.warn({ tag: this.validateUser.name, msg: `User not found and autoCreateUser is disabled` })throw new HttpException('User not found', HttpStatus.UNAUTHORIZED)}const identity = this.createIdentity(entry, password)user = await this.updateOrCreateUser(identity, user)- this.usersManager.updateAccesses(user, ip, true).catch((e: Error) => this.logger.error(`${this.validateUser.name} : ${e}`))+ this.usersManager.updateAccesses(user, ip, true).catch((e: Error) => this.logger.error({ tag: this.validateUser.name, msg: `${e}` }))return user}@@ -106,7 +109,7 @@ export class AuthProviderLDAP implements AuthProvider {await client.bind(this.ldapConfig.serviceBindDN, this.ldapConfig.serviceBindPassword)const result = await this.findUserEntry(ldapLogin, client)if (!result || !result.userDn) {- this.logger.warn(`${this.checkAuth.name} - no LDAP entry found for : ${login}`)+ this.logger.warn({ tag: this.checkAuth.name, msg: `no LDAP entry found for : ${login}` })return false}const { entry, userDn } = result@@ -127,7 +130,7 @@ export class AuthProviderLDAP implements AuthProvider {}}if (error) {- this.logger.error(`${this.checkAuth.name} - ${error}`)+ this.logger.error({ tag: this.checkAuth.name, msg: `${error}` })if (CONNECT_ERROR_CODE.has(error.code)) {throw new Error('Authentication service error')}@@ -151,13 +154,13 @@ export class AuthProviderLDAP implements AuthProvider {})if (searchEntries.length === 0) {- this.logger.debug(`${this.findUserEntry.name} - search filter : ${searchFilter}`)- this.logger.warn(`${this.findUserEntry.name} - no LDAP entry found for : ${login}`)+ this.logger.debug({ tag: this.findUserEntry.name, msg: `search filter : ${searchFilter}` })+ this.logger.warn({ tag: this.findUserEntry.name, msg: `no LDAP entry found for : ${login}` })return false}if (searchEntries.length > 1) {- this.logger.warn(`${this.findUserEntry.name} - multiple LDAP entries found for : ${login}, using first one`)+ this.logger.warn({ tag: this.findUserEntry.name, msg: `multiple LDAP entries found for : ${login}, using first one` })}const rawEntry = searchEntries[0]@@ -174,8 +177,8 @@ export class AuthProviderLDAP implements AuthProvider {// Return the first matching entry.return { entry, userDn }} catch (e) {- this.logger.debug(`${this.findUserEntry.name} - search filter : ${searchFilter}`)- this.logger.error(`${this.findUserEntry.name} - ${login} : ${e}`)+ this.logger.debug({ tag: this.findUserEntry.name, msg: `search filter : ${searchFilter}` })+ this.logger.error({ tag: this.findUserEntry.name, msg: `${login} : ${e}` })return false}}@@ -188,14 +191,14 @@ export class AuthProviderLDAP implements AuthProvider {const createdUser = await this.adminUsersManager.createUserOrGuest(identity, identity.role)const freshUser = await this.usersManager.fromUserId(createdUser.id)if (!freshUser) {- this.logger.error(`${this.updateOrCreateUser.name} - user was not found : ${createdUser.login} (${createdUser.id})`)+ this.logger.error({ tag: this.updateOrCreateUser.name, msg: `user was not found : ${createdUser.login} (${createdUser.id})` })throw new HttpException('User not found', HttpStatus.NOT_FOUND)}return freshUser}if (identity.login !== user.login) {- this.logger.error(`${this.updateOrCreateUser.name} - user login mismatch : ${identity.login} !== ${user.login}`)+ this.logger.error({ tag: this.updateOrCreateUser.name, msg: `user login mismatch : ${identity.login} !== ${user.login}` })throw new HttpException('Account matching error', HttpStatus.FORBIDDEN)}@@ -238,7 +241,7 @@ export class AuthProviderLDAP implements AuthProvider {user.setFullName(true)}} catch (e) {- this.logger.warn(`${this.updateOrCreateUser.name} - unable to update user *${user.login}* : ${e}`)+ this.logger.warn({ tag: this.updateOrCreateUser.name, msg: `unable to update user *${user.login}* : ${e}` })}}return user@@ -393,7 +396,7 @@ export class AuthProviderLDAP implements AuthProvider {// Any matching entry implies membership.return searchEntries.length > 0} catch (e) {- this.logger.warn(`${this.isMemberOfGroupOfNames.name} - ${e}`)+ this.logger.warn({ tag: this.isMemberOfGroupOfNames.name, msg: `${e}` })return false}}@@ -412,11 +415,11 @@ export class AuthProviderLDAP implements AuthProvider {// Prefer the most specific LDAP error when multiple errors are returned.if (error?.errors?.length) {for (const err of error.errors) {- this.logger.warn(`${this.checkAuth.name} - ${attemptedBindDN} : ${err}`)+ this.logger.warn({ tag: this.handleBindError.name, msg: `${attemptedBindDN} : ${err}` })}return error.errors[error.errors.length - 1]}- this.logger.warn(`${this.checkAuth.name} - ${attemptedBindDN} : ${error}`)+ this.logger.warn({ tag: this.handleBindError.name, msg: `${attemptedBindDN} : ${error}` })return error}}diff --git a/backend/src/authentication/providers/mysql/auth-provider-mysql.service.ts b/backend/src/authentication/providers/mysql/auth-provider-mysql.service.tsindex d47246ab..b329155d 100644--- a/backend/src/authentication/providers/mysql/auth-provider-mysql.service.ts+++ b/backend/src/authentication/providers/mysql/auth-provider-mysql.service.ts@@ -16,14 +16,14 @@ export class AuthProviderMySQL implements AuthProvider {try {user = await this.usersManager.findUser(loginOrEmail, false)} catch (e) {- this.logger.error(`${this.validateUser.name} - ${e}`)+ this.logger.error({ tag: this.validateUser.name, msg: `${e}` })throw new HttpException(CONNECT_ERROR_CODE.has(e.cause?.code) ? 'Authentication service error' : e.cause?.code || e.message,HttpStatus.INTERNAL_SERVER_ERROR)}if (!user) {- this.logger.warn(`${this.validateUser.name} - login or email not found for *${loginOrEmail}*`)+ this.logger.warn({ tag: this.validateUser.name, msg: `login or email not found for *${loginOrEmail}*` })return null}return await this.usersManager.logUser(user, password, ip, scope)diff --git a/backend/src/authentication/providers/oidc/auth-provider-oidc.service.ts b/backend/src/authentication/providers/oidc/auth-provider-oidc.service.tsindex 3f764cd2..5ef40858 100644--- a/backend/src/authentication/providers/oidc/auth-provider-oidc.service.ts+++ b/backend/src/authentication/providers/oidc/auth-provider-oidc.service.ts@@ -172,10 +172,10 @@ export class AuthProviderOIDC implements AuthProvider {return await this.processUserInfo(userInfo, req.ip)} catch (error: AuthorizationResponseError | HttpException | any) {if (error instanceof AuthorizationResponseError) {- this.logger.error(`${this.handleCallback.name} - OIDC callback error: ${error.code} - ${error.error_description}`)+ this.logger.error({ tag: this.handleCallback.name, msg: `OIDC callback error: ${error.code} - ${error.error_description}` })throw new HttpException(error.error_description, HttpStatus.BAD_REQUEST)} else {- this.logger.error(`${this.handleCallback.name} - OIDC callback error: ${error}`)+ this.logger.error({ tag: this.handleCallback.name, msg: `OIDC callback error: ${error}` })throw new HttpException(error.error_description ?? 'OIDC authentication failed',error instanceof HttpException ? error.getStatus() : (error.status ?? HttpStatus.INTERNAL_SERVER_ERROR)@@ -237,10 +237,10 @@ export class AuthProviderOIDC implements AuthProvider {timeout: 6000})- this.logger.log(`${this.initializeOIDCClient.name} - OIDC client initialized successfully for issuer: ${this.oidcConfig.issuerUrl}`)+ this.logger.log({ tag: this.initializeOIDCClient.name, msg: `OIDC client initialized successfully for issuer: ${this.oidcConfig.issuerUrl}` })return config} catch (error) {- this.logger.error(`${this.initializeOIDCClient.name} - OIDC client initialization failed: ${error?.cause || error}`)+ this.logger.error({ tag: this.initializeOIDCClient.name, msg: `OIDC client initialization failed: ${error?.cause || error}` })switch (error.cause?.code) {case 'ECONNREFUSED':case 'ENOTFOUND':@@ -283,7 +283,7 @@ export class AuthProviderOIDC implements AuthProvider {let user: UserModel = await this.usersManager.findUser(email || login, false)if (!user && !this.oidcConfig.options.autoCreateUser) {- this.logger.warn(`${this.validateUser.name} - User not found and autoCreateUser is disabled`)+ this.logger.warn({ tag: this.processUserInfo.name, msg: `User not found and autoCreateUser is disabled` })throw new HttpException('User not found', HttpStatus.UNAUTHORIZED)}@@ -297,7 +297,7 @@ export class AuthProviderOIDC implements AuthProvider {user = await this.updateOrCreateUser(identity, user)// Update user access log- this.usersManager.updateAccesses(user, ip, true).catch((e: Error) => this.logger.error(`${this.processUserInfo.name} : ${e}`))+ this.usersManager.updateAccesses(user, ip, true).catch((e: Error) => this.logger.error({ tag: this.processUserInfo.name, msg: `${e}` }))return user}@@ -350,7 +350,7 @@ export class AuthProviderOIDC implements AuthProvider {const createdUser = await this.adminUsersManager.createUserOrGuest(userWithPassword, identity.role)const freshUser = await this.usersManager.fromUserId(createdUser.id)if (!freshUser) {- this.logger.error(`${this.updateOrCreateUser.name} - user was not found : ${createdUser.login} (${createdUser.id})`)+ this.logger.error({ tag: this.updateOrCreateUser.name, msg: `user was not found : ${createdUser.login} (${createdUser.id})` })throw new HttpException('User not found', HttpStatus.NOT_FOUND)}return freshUser@@ -384,7 +384,7 @@ export class AuthProviderOIDC implements AuthProvider {user.setFullName(true)}} catch (e) {- this.logger.warn(`${this.updateOrCreateUser.name} - unable to update user *${user.login}* : ${e}`)+ this.logger.warn({ tag: this.updateOrCreateUser.name, msg: `unable to update user *${user.login}* : ${e}` })}}diff --git a/backend/src/authentication/providers/two-fa/auth-provider-two-fa.service.ts b/backend/src/authentication/providers/two-fa/auth-provider-two-fa.service.tsindex ed07a0f1..96771251 100644--- a/backend/src/authentication/providers/two-fa/auth-provider-two-fa.service.ts+++ b/backend/src/authentication/providers/two-fa/auth-provider-two-fa.service.ts@@ -85,7 +85,7 @@ export class AuthProvider2FA {const auth = verifyDto.isRecoveryCode? await this.validateRecoveryCode(req.user.id, verifyDto.code, user.secrets.recoveryCodes): this.validateTwoFactorCode(verifyDto.code, secret)- this.usersManager.updateAccesses(user, req.ip, auth.success, true).catch((e: Error) => this.logger.error(`${this.verify.name} - ${e}`))+ this.usersManager.updateAccesses(user, req.ip, auth.success, true).catch((e: Error) => this.logger.error({ tag: this.verify.name, msg: `${e}` }))return fromLogin ? [auth, user] : auth}@@ -97,7 +97,7 @@ export class AuthProvider2FA {} catch (e) {auth.success = falseauth.message = e.message- this.logger.error(`${this.adminResetUserTwoFa.name} - ${e}`)+ this.logger.error({ tag: this.adminResetUserTwoFa.name, msg: `${e}` })}return auth}@@ -105,7 +105,7 @@ export class AuthProvider2FA {async loadUser(userId: number, ip: string) {const user: UserModel = await this.usersManager.fromUserId(userId)if (!user) {- this.logger.warn(`User ${userId} (${ip}) not found`)+ this.logger.warn({ tag: this.loadUser.name, msg: `User ${userId} (${ip}) not found` })throw new HttpException(`User not found`, HttpStatus.NOT_FOUND)}this.usersManager.validateUserAccess(user, ip)@@ -116,7 +116,9 @@ export class AuthProvider2FA {// This function works with any authentication method, provided that// the authentication service implements proper user password updates in the database.if (!(await this.usersManager.compareUserPassword(user.id, password))) {- this.usersManager.updateAccesses(user, ip, false, true).catch((e: Error) => this.logger.error(`${this.enableTwoFactor.name} - ${e}`))+ this.usersManager+ .updateAccesses(user, ip, false, true)+ .catch((e: Error) => this.logger.error({ tag: this.verifyUserPassword.name, msg: `${e}` }))throw new HttpException('Incorrect code or password', HttpStatus.BAD_REQUEST)}}@@ -131,7 +133,7 @@ export class AuthProvider2FA {auth.success = Totp.validate({ passcode: code, secret: this.decryptSecret(encryptedSecret), drift: 1 })if (!auth.success) auth.message = 'Incorrect code or password'} catch (e) {- this.logger.error(`${this.validateTwoFactorCode.name} - ${e}`)+ this.logger.error({ tag: this.validateTwoFactorCode.name, msg: `${e}` })auth.message = e.message}return auth@@ -160,7 +162,7 @@ export class AuthProvider2FA {auth.message = 'Invalid code'}} catch (e) {- this.logger.error(`${this.validateRecoveryCode.name} - ${e}`)+ this.logger.error({ tag: this.validateRecoveryCode.name, msg: `${e}` })auth.message = e.message}return auth@@ -205,6 +207,6 @@ export class AuthProvider2FA {}this.notificationsManager.sendEmailNotification([req.user], notification)- .catch((e: Error) => this.logger.error(`${this.sendEmailNotification.name} - ${e}`))+ .catch((e: Error) => this.logger.error({ tag: this.sendEmailNotification.name, msg: `${e}` }))}}diff --git a/backend/src/configuration/config.logger.ts b/backend/src/configuration/config.logger.tsindex bad055f4..e99bea5d 100644--- a/backend/src/configuration/config.logger.ts+++ b/backend/src/configuration/config.logger.ts@@ -42,13 +42,13 @@ export const configLogger = (loggerConfig: LoggerConfig) =>transport: {target: 'pino-pretty',options: {- ignore: 'hostname,context,reqId,req,res,user,userAgent,responseTime',+ ignore: 'hostname,context,reqId,req,res,user,userAgent,responseTime,tag',hideObject: false,singleLine: false,colorize: loggerConfig.colorize,colorizeObjects: false,translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',- messageFormat: `[{context}]{if user} <{user}> {end} ${+ messageFormat: `[{context}]{if tag} [{tag}] {end}{if user} <{user}> {end} ${loggerConfig.colorize ? '\x1b[37m' : ''}{msg}{if res} ({res.contentLength} bytes in {responseTime}ms) {userAgent}{end}{if reqId} | {reqId}{end}`,destination: loggerConfig.stdout ? 1 : loggerConfig.filePath,diff --git a/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.ts b/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.tsindex 66788e8a..98b13972 100644--- a/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.ts+++ b/backend/src/infrastructure/cache/adapters/mysql-cache.adapter.ts@@ -111,7 +111,7 @@ export class MysqlCacheAdapter implements Cache {})return true} catch (e) {- this.logger.error(`${this.set.name} - ${e}`)+ this.logger.error({ tag: this.set.name, msg: `${e}` })return false}}@@ -152,7 +152,7 @@ export class MysqlCacheAdapter implements Cache {try {await this.db.delete(cache).where(this.whereExpired())} catch (e) {- this.logger.error(`${this.clearExpiredKeys.name} - ${e?.code || e}`)+ this.logger.error({ tag: this.clearExpiredKeys.name, msg: `${e?.code || e}` })}}}diff --git a/backend/src/infrastructure/cache/cache.decorator.ts b/backend/src/infrastructure/cache/cache.decorator.tsindex 0204d5bf..29f555d3 100644--- a/backend/src/infrastructure/cache/cache.decorator.ts+++ b/backend/src/infrastructure/cache/cache.decorator.ts@@ -16,13 +16,13 @@ export function CacheDecorator(TTL = 120, updateCache: boolean = false) {if (cacheResult !== undefined) {if (updateCache) {originalMethod.apply(this, args).then((r: any) => {- this.cache.set(cacheKey, r, TTL).catch((e: Error) => this.logger.error(`${memoize.name} - ${e}`))+ this.cache.set(cacheKey, r, TTL).catch((e: Error) => this.logger.error({ tag: memoize.name, msg: `${e}` }))})}return cacheResult}const r: any = await originalMethod.apply(this, args)- this.cache.set(cacheKey, r, TTL).catch((e: Error) => this.logger.error(`${memoize.name} - ${e}`))+ this.cache.set(cacheKey, r, TTL).catch((e: Error) => this.logger.error({ tag: memoize.name, msg: `${e}` }))return r} catch (e) {console.error(e)