You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Add more logging scopes to session IDs
This uses prefix chaining to correlate several scopes together.
This commit is contained in:
@@ -656,13 +656,14 @@ OlmDevice.prototype.getSessionIdsForDevice = async function(theirDeviceIdentityK
|
|||||||
* @param {boolean} nowait Don't wait for an in-progress session to complete.
|
* @param {boolean} nowait Don't wait for an in-progress session to complete.
|
||||||
* This should only be set to true of the calling function is the function
|
* This should only be set to true of the calling function is the function
|
||||||
* that marked the session as being in-progress.
|
* that marked the session as being in-progress.
|
||||||
|
* @param {Logger} [log] A possibly customised log
|
||||||
* @return {Promise<?string>} session id, or null if no established session
|
* @return {Promise<?string>} session id, or null if no established session
|
||||||
*/
|
*/
|
||||||
OlmDevice.prototype.getSessionIdForDevice = async function(
|
OlmDevice.prototype.getSessionIdForDevice = async function(
|
||||||
theirDeviceIdentityKey, nowait,
|
theirDeviceIdentityKey, nowait, log,
|
||||||
) {
|
) {
|
||||||
const sessionInfos = await this.getSessionInfoForDevice(
|
const sessionInfos = await this.getSessionInfoForDevice(
|
||||||
theirDeviceIdentityKey, nowait,
|
theirDeviceIdentityKey, nowait, log,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (sessionInfos.length === 0) {
|
if (sessionInfos.length === 0) {
|
||||||
@@ -702,10 +703,13 @@ OlmDevice.prototype.getSessionIdForDevice = async function(
|
|||||||
* @param {boolean} nowait Don't wait for an in-progress session to complete.
|
* @param {boolean} nowait Don't wait for an in-progress session to complete.
|
||||||
* This should only be set to true of the calling function is the function
|
* This should only be set to true of the calling function is the function
|
||||||
* that marked the session as being in-progress.
|
* that marked the session as being in-progress.
|
||||||
|
* @param {Logger} [log] A possibly customised log
|
||||||
* @return {Array.<{sessionId: string, hasReceivedMessage: Boolean}>}
|
* @return {Array.<{sessionId: string, hasReceivedMessage: Boolean}>}
|
||||||
*/
|
*/
|
||||||
OlmDevice.prototype.getSessionInfoForDevice = async function(deviceIdentityKey, nowait) {
|
OlmDevice.prototype.getSessionInfoForDevice = async function(
|
||||||
const log = logger.withPrefix("[getSessionInfoForDevice]");
|
deviceIdentityKey, nowait, log = logger,
|
||||||
|
) {
|
||||||
|
log = log.withPrefix("[getSessionInfoForDevice]");
|
||||||
|
|
||||||
if (this._sessionsInProgress[deviceIdentityKey] && !nowait) {
|
if (this._sessionsInProgress[deviceIdentityKey] && !nowait) {
|
||||||
log.debug(`Waiting for Olm session for ${deviceIdentityKey} to be created`);
|
log.debug(`Waiting for Olm session for ${deviceIdentityKey} to be created`);
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ export async function getExistingOlmSessions(
|
|||||||
* @param {Array} [failedServers] An array to fill with remote servers that
|
* @param {Array} [failedServers] An array to fill with remote servers that
|
||||||
* failed to respond to one-time-key requests.
|
* failed to respond to one-time-key requests.
|
||||||
*
|
*
|
||||||
* @param {Object} [log] A possibly customised log
|
* @param {Logger} [log] A possibly customised log
|
||||||
*
|
*
|
||||||
* @return {Promise} resolves once the sessions are complete, to
|
* @return {Promise} resolves once the sessions are complete, to
|
||||||
* an Object mapping from userId to deviceId to
|
* an Object mapping from userId to deviceId to
|
||||||
@@ -257,7 +257,7 @@ export async function ensureOlmSessionsForDevices(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const sessionId = await olmDevice.getSessionIdForDevice(
|
const sessionId = await olmDevice.getSessionIdForDevice(
|
||||||
key, resolveSession[key],
|
key, resolveSession[key], log,
|
||||||
);
|
);
|
||||||
log.debug(`Got Olm session ${sessionId} ${forWhom}`);
|
log.debug(`Got Olm session ${sessionId} ${forWhom}`);
|
||||||
if (sessionId !== null && resolveSession[key]) {
|
if (sessionId !== null && resolveSession[key]) {
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ export class IndexedDBCryptoStore {
|
|||||||
* @param {function(*)} func Function called with the
|
* @param {function(*)} func Function called with the
|
||||||
* transaction object: an opaque object that should be passed
|
* transaction object: an opaque object that should be passed
|
||||||
* to store functions.
|
* to store functions.
|
||||||
* @param {object} [log] A possibly customised log
|
* @param {Logger} [log] A possibly customised log
|
||||||
* @return {Promise} Promise that resolves with the result of the `func`
|
* @return {Promise} Promise that resolves with the result of the `func`
|
||||||
* when the transaction is complete. If the backend is
|
* when the transaction is complete. If the backend is
|
||||||
* async (ie. the indexeddb backend) any of the callback
|
* async (ie. the indexeddb backend) any of the callback
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ interface PrefixedLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function extendLogger(logger: PrefixedLogger) {
|
function extendLogger(logger: PrefixedLogger) {
|
||||||
logger.withPrefix = function(prefix: string) {
|
logger.withPrefix = function(prefix: string): PrefixedLogger {
|
||||||
return getPrefixedLogger(this.prefix + prefix);
|
const existingPrefix = this.prefix || "";
|
||||||
|
return getPrefixedLogger(existingPrefix + prefix);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user