mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Include altSessionId in logs
Summary: Adds altSessionId to log output. Test Plan: Tested manually. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3355
This commit is contained in:
@@ -26,14 +26,17 @@ interface JsonErrorHandlerOptions {
|
||||
* Currently allows for toggling of logging request bodies and params.
|
||||
*/
|
||||
const buildJsonErrorHandler = (options: JsonErrorHandlerOptions = {}): express.ErrorRequestHandler => {
|
||||
const {shouldLogBody, shouldLogParams} = options;
|
||||
return (err, req, res, _next) => {
|
||||
const mreq = req as RequestWithLogin;
|
||||
log.warn(
|
||||
"Error during api call to %s: (%s)%s%s%s",
|
||||
req.path, err.message, mreq.userId !== undefined ? ` user ${mreq.userId}` : '',
|
||||
options.shouldLogParams !== false ? ` params ${JSON.stringify(req.params)}` : '',
|
||||
options.shouldLogBody !== false ? ` body ${JSON.stringify(req.body)}` : '',
|
||||
);
|
||||
const meta = {
|
||||
path: mreq.path,
|
||||
userId: mreq.userId,
|
||||
altSessionId: mreq.altSessionId,
|
||||
body: shouldLogBody !== false ? req.body : undefined,
|
||||
params: shouldLogParams !== false ? req.params : undefined,
|
||||
};
|
||||
log.rawWarn(`Error during api call to ${meta.path}: ${err.message}`, meta);
|
||||
let details = err.details && {...err.details};
|
||||
const status = details?.status || err.status || 500;
|
||||
if (details) {
|
||||
|
||||
Reference in New Issue
Block a user