mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-06 01:23:46 +00:00
feat: keep the multiline log in single log (#4281)
This commit is contained in:
@@ -28,13 +28,12 @@ export class ExceptionLogger implements ExceptionFilter {
|
||||
);
|
||||
this.logger.error(
|
||||
new Error(
|
||||
`${requestId ? `requestId-${requestId}:` : ''}${exception.message}`,
|
||||
`${requestId ? `requestId-${requestId}: ` : ''}${exception.message}${
|
||||
shouldVerboseLog ? '\n' + exception.stack : ''
|
||||
}}`,
|
||||
{ cause: exception }
|
||||
)
|
||||
);
|
||||
if (shouldVerboseLog) {
|
||||
this.logger.error(exception.stack);
|
||||
}
|
||||
|
||||
if (host.getType<GqlContextType>() === 'graphql') {
|
||||
return;
|
||||
|
||||
@@ -141,7 +141,7 @@ export class NextAuthController {
|
||||
}
|
||||
|
||||
if (redirect?.endsWith('api/auth/error?error=AccessDenied')) {
|
||||
this.logger.log('Early access redirect headers ', req.headers);
|
||||
this.logger.log(`Early access redirect headers: ${req.headers}`);
|
||||
this.metrics.authFailCounter(1, {
|
||||
reason: 'no_early_access_permission',
|
||||
});
|
||||
|
||||
@@ -74,8 +74,9 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.error(
|
||||
`Failed to apply updates, index: ${i}`,
|
||||
updates.map(u => u.toString('hex'))
|
||||
`Failed to apply updates, index: ${i}\nUpdate: ${updates
|
||||
.map(u => u.toString('hex'))
|
||||
.join('\n')}`
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -109,13 +110,12 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
|
||||
}
|
||||
} catch (e) {
|
||||
this.metrics.jwstCodecFail(1, {});
|
||||
this.logger.warn(`jwst apply update failed for :${guid}`, e);
|
||||
this.logger.warn(`jwst apply update failed for ${guid}: ${e}`);
|
||||
log = true;
|
||||
} finally {
|
||||
if (log) {
|
||||
this.logger.warn(
|
||||
'Updates:',
|
||||
updates.map(u => u.toString('hex'))
|
||||
`Updates: ${updates.map(u => u.toString('hex')).join('\n')}`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -288,7 +288,7 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
|
||||
.catch(
|
||||
// transaction failed, it's safe to ignore
|
||||
e => {
|
||||
this.logger.error('Failed to fetch updates', e);
|
||||
this.logger.error(`Failed to fetch updates: ${e}`);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -322,7 +322,7 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
|
||||
await this.upsert(workspaceId, id, merged);
|
||||
} catch (e) {
|
||||
// failed to merge updates, put them back
|
||||
this.logger.error('Failed to merge updates', e);
|
||||
this.logger.error(`Failed to merge updates: ${e}`);
|
||||
|
||||
await this.db.update
|
||||
.createMany({
|
||||
@@ -334,7 +334,7 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {
|
||||
})
|
||||
.catch(e => {
|
||||
// failed to recover, fallback TBD
|
||||
this.logger.error('Fetal: failed to put updates back to db', e);
|
||||
this.logger.error(`Fetal: failed to put updates back to db: ${e}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,12 +140,11 @@ export class RedisDocManager extends DocManager {
|
||||
.ltrim(updateKey, updates.length, -1)
|
||||
// safe, fallback to mergeUpdates
|
||||
.catch(e => {
|
||||
this.logger.error('Failed to remove merged updates from Redis', e);
|
||||
this.logger.error(`Failed to remove merged updates from Redis: ${e}`);
|
||||
});
|
||||
} catch (e) {
|
||||
this.logger.error(
|
||||
`Failed to merge updates with snapshot for ${pendingDoc}`,
|
||||
e
|
||||
`Failed to merge updates with snapshot for ${pendingDoc}: ${e}`
|
||||
);
|
||||
await this.redis.sadd(pending, `${workspaceId}:${id}`).catch(() => null); // safe
|
||||
} finally {
|
||||
|
||||
@@ -41,7 +41,9 @@ export class WorkspacesController {
|
||||
const blob = await this.storage.getBlob(workspaceId, name);
|
||||
|
||||
if (!blob) {
|
||||
throw new NotFoundException('Blob not found');
|
||||
throw new NotFoundException(
|
||||
`Blob not found in workspace ${workspaceId}: ${name}`
|
||||
);
|
||||
}
|
||||
|
||||
res.setHeader('content-type', blob.contentType);
|
||||
@@ -78,6 +80,6 @@ export class WorkspacesController {
|
||||
|
||||
res.setHeader('content-type', 'application/octet-stream');
|
||||
res.send(update);
|
||||
this.logger.debug('workspaces doc api: ', format(process.hrtime(start)));
|
||||
this.logger.debug(`workspaces doc api: ${format(process.hrtime(start))}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user