mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +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:
parent
bf8769bc42
commit
4c5de16e2d
@ -300,9 +300,17 @@ export async function addRequestUser(dbManager: HomeDBManager, permitStore: IPer
|
|||||||
mreq.users = [dbManager.makeFullUser(anon)];
|
mreq.users = [dbManager.makeFullUser(anon)];
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Auth[%s]: id %s email %s host %s path %s org %s%s", mreq.method,
|
const meta = {
|
||||||
mreq.userId, mreq.user?.loginEmail, mreq.get('host'), mreq.path, mreq.org,
|
customHostSession,
|
||||||
customHostSession);
|
method: mreq.method,
|
||||||
|
host: mreq.get('host'),
|
||||||
|
path: mreq.path,
|
||||||
|
org: mreq.org,
|
||||||
|
email: mreq.user?.loginEmail,
|
||||||
|
userId: mreq.userId,
|
||||||
|
altSessionId: mreq.altSessionId,
|
||||||
|
};
|
||||||
|
log.rawDebug(`Auth[${meta.method}]: ${meta.host} ${meta.path}`, meta);
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
@ -365,6 +365,8 @@ export class Client {
|
|||||||
meta.age = Math.floor(moment.duration(moment().diff(this._firstLoginAt)).asDays());
|
meta.age = Math.floor(moment.duration(moment().diff(this._firstLoginAt)).asDays());
|
||||||
}
|
}
|
||||||
if (this._org) { meta.org = this._org; }
|
if (this._org) { meta.org = this._org; }
|
||||||
|
const altSessionId = this.getAltSessionId();
|
||||||
|
if (altSessionId) { meta.altSessionId = altSessionId; }
|
||||||
meta.clientId = this.clientId; // identifies a client connection, essentially a websocket
|
meta.clientId = this.clientId; // identifies a client connection, essentially a websocket
|
||||||
meta.counter = this._counter; // identifies a GristWSConnection in the connected browser tab
|
meta.counter = this._counter; // identifies a GristWSConnection in the connected browser tab
|
||||||
return meta;
|
return meta;
|
||||||
|
@ -581,6 +581,7 @@ export class FlexServer implements GristServer {
|
|||||||
org: mreq.org,
|
org: mreq.org,
|
||||||
email: mreq.user && mreq.user.loginEmail,
|
email: mreq.user && mreq.user.loginEmail,
|
||||||
userId: mreq.userId,
|
userId: mreq.userId,
|
||||||
|
altSessionId: mreq.altSessionId,
|
||||||
});
|
});
|
||||||
return resp.status(200).send();
|
return resp.status(200).send();
|
||||||
}));
|
}));
|
||||||
|
@ -22,9 +22,11 @@ export async function exportToDrive(
|
|||||||
throw new Error("No access token - Can't send file to Google Drive");
|
throw new Error("No access token - Can't send file to Google Drive");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mreq = req as RequestWithLogin;
|
||||||
const meta = {
|
const meta = {
|
||||||
docId : activeDoc.docName,
|
docId: activeDoc.docName,
|
||||||
userId : (req as RequestWithLogin).userId
|
userId: mreq.userId,
|
||||||
|
altSessionId: mreq.altSessionId,
|
||||||
};
|
};
|
||||||
// Prepare file for exporting.
|
// Prepare file for exporting.
|
||||||
log.debug(`Export to drive - Preparing file for export`, meta);
|
log.debug(`Export to drive - Preparing file for export`, meta);
|
||||||
|
@ -243,6 +243,7 @@ export class Sharing {
|
|||||||
parentActionHash: null, // Gets set below by _actionHistory.recordNext...
|
parentActionHash: null, // Gets set below by _actionHistory.recordNext...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const altSessionId = client?.getAltSessionId();
|
||||||
const logMeta = {
|
const logMeta = {
|
||||||
actionNum,
|
actionNum,
|
||||||
linkId: info.linkId,
|
linkId: info.linkId,
|
||||||
@ -250,6 +251,7 @@ export class Sharing {
|
|||||||
numDocActions: localActionBundle.stored.length,
|
numDocActions: localActionBundle.stored.length,
|
||||||
numRows: localActionBundle.stored.reduce((n, env) => n + getNumRows(env[1]), 0),
|
numRows: localActionBundle.stored.reduce((n, env) => n + getNumRows(env[1]), 0),
|
||||||
author: info.user,
|
author: info.user,
|
||||||
|
...(altSessionId ? {session: altSessionId}: {}),
|
||||||
};
|
};
|
||||||
this._log.rawLog('debug', docSession, '_doApplyUserActions', logMeta);
|
this._log.rawLog('debug', docSession, '_doApplyUserActions', logMeta);
|
||||||
if (LOG_ACTION_BUNDLE) {
|
if (LOG_ACTION_BUNDLE) {
|
||||||
|
@ -26,14 +26,17 @@ interface JsonErrorHandlerOptions {
|
|||||||
* Currently allows for toggling of logging request bodies and params.
|
* Currently allows for toggling of logging request bodies and params.
|
||||||
*/
|
*/
|
||||||
const buildJsonErrorHandler = (options: JsonErrorHandlerOptions = {}): express.ErrorRequestHandler => {
|
const buildJsonErrorHandler = (options: JsonErrorHandlerOptions = {}): express.ErrorRequestHandler => {
|
||||||
|
const {shouldLogBody, shouldLogParams} = options;
|
||||||
return (err, req, res, _next) => {
|
return (err, req, res, _next) => {
|
||||||
const mreq = req as RequestWithLogin;
|
const mreq = req as RequestWithLogin;
|
||||||
log.warn(
|
const meta = {
|
||||||
"Error during api call to %s: (%s)%s%s%s",
|
path: mreq.path,
|
||||||
req.path, err.message, mreq.userId !== undefined ? ` user ${mreq.userId}` : '',
|
userId: mreq.userId,
|
||||||
options.shouldLogParams !== false ? ` params ${JSON.stringify(req.params)}` : '',
|
altSessionId: mreq.altSessionId,
|
||||||
options.shouldLogBody !== false ? ` body ${JSON.stringify(req.body)}` : '',
|
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};
|
let details = err.details && {...err.details};
|
||||||
const status = details?.status || err.status || 500;
|
const status = details?.status || err.status || 500;
|
||||||
if (details) {
|
if (details) {
|
||||||
|
@ -186,6 +186,7 @@ export async function sendReply<T>(
|
|||||||
log.rawDebug('api call', {
|
log.rawDebug('api call', {
|
||||||
url: req.url,
|
url: req.url,
|
||||||
userId: mreq.userId,
|
userId: mreq.userId,
|
||||||
|
altSessionId: mreq.altSessionId,
|
||||||
email: mreq.user && mreq.user.loginEmail,
|
email: mreq.user && mreq.user.loginEmail,
|
||||||
org: mreq.org,
|
org: mreq.org,
|
||||||
params: req.params,
|
params: req.params,
|
||||||
|
@ -116,6 +116,7 @@ export async function handleOptionalUpload(req: Request, res: Response): Promise
|
|||||||
org: mreq.org,
|
org: mreq.org,
|
||||||
email: mreq.user && mreq.user.loginEmail,
|
email: mreq.user && mreq.user.loginEmail,
|
||||||
userId: mreq.userId,
|
userId: mreq.userId,
|
||||||
|
altSessionId: mreq.altSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
log.rawDebug(`Prepared to receive upload into tmp dir ${tmpDir}`, meta);
|
log.rawDebug(`Prepared to receive upload into tmp dir ${tmpDir}`, meta);
|
||||||
|
Loading…
Reference in New Issue
Block a user