Skip to content

Commit 8f8d565

Browse files
Improve logging around sessions.
1 parent 0516a98 commit 8f8d565

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

AxolotlKit/Classes/SessionCipher.m

+10-9
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ - (instancetype)initWithSessionStore:(id<SessionStore>)sessionStore
112112
recipientId:self.recipientId
113113
direction:TSMessageDirectionOutgoing
114114
protocolContext:protocolContext]) {
115-
DDLogWarn(
115+
OWSLogWarn(
116116
@"%@ Previously known identity key for while encrypting for recipient: %@", self.tag, self.recipientId);
117117
@throw [NSException exceptionWithName:UntrustedIdentityKeyException
118118
reason:@"There is a previously known identity key."
@@ -140,7 +140,8 @@ - (instancetype)initWithSessionStore:(id<SessionStore>)sessionStore
140140
PendingPreKey *items = [sessionState unacknowledgedPreKeyMessageItems];
141141
int localRegistrationId = [sessionState localRegistrationId];
142142

143-
DDLogInfo(@"Building PreKeyWhisperMessage for: %@ with preKeyId: %d", self.recipientId, items.preKeyId);
143+
OWSLogInfo(@"Building PreKeyWhisperMessage for: %@.%lu with preKeyId: %d",
144+
self.recipientId, (unsigned long) self.deviceId, items.preKeyId);
144145

145146
cipherMessage =
146147
[[PreKeyWhisperMessage alloc] init_throws_withWhisperMessage:cipherMessage
@@ -240,7 +241,7 @@ - (NSData *)throws_decryptWhisperMessage:(WhisperMessage *)whisperMessage protoc
240241
recipientId:self.recipientId
241242
direction:TSMessageDirectionIncoming
242243
protocolContext:protocolContext]) {
243-
DDLogWarn(
244+
OWSLogWarn(
244245
@"%@ Previously known identity key for while decrypting from recipient: %@", self.tag, self.recipientId);
245246
@throw [NSException exceptionWithName:UntrustedIdentityKeyException
246247
reason:@"There is a previously known identity key."
@@ -272,7 +273,7 @@ - (NSData *)throws_decryptWithSessionRecord:(SessionRecord *)sessionRecord
272273
NSData *decryptedData = [self throws_decryptWithSessionState:sessionState
273274
whisperMessage:whisperMessage
274275
protocolContext:protocolContext];
275-
DDLogDebug(@"%@ successfully decrypted with current session state: %@", self.tag, sessionState);
276+
OWSLogDebug(@"%@ successfully decrypted with current session state: %@", self.tag, sessionState);
276277
return decryptedData;
277278
}
278279
@catch (NSException *exception) {
@@ -293,7 +294,7 @@ - (NSData *)throws_decryptWithSessionRecord:(SessionRecord *)sessionRecord
293294
decryptedData = [self throws_decryptWithSessionState:previousState
294295
whisperMessage:whisperMessage
295296
protocolContext:protocolContext];
296-
DDLogInfo(@"%@ successfully decrypted with PREVIOUS session state: %@", self.tag, previousState);
297+
OWSLogInfo(@"%@ successfully decrypted with PREVIOUS session state: %@", self.tag, previousState);
297298
OWSAssert(decryptedData != nil);
298299
stateToPromoteIdx = idx;
299300
*stop = YES;
@@ -305,7 +306,7 @@ - (NSData *)throws_decryptWithSessionRecord:(SessionRecord *)sessionRecord
305306
if (decryptedData) {
306307
SessionState *sessionStateToPromote = [sessionRecord previousSessionStates][stateToPromoteIdx];
307308
OWSAssert(sessionStateToPromote != nil);
308-
DDLogInfo(@"%@ promoting session: %@", self.tag, sessionStateToPromote);
309+
OWSLogInfo(@"%@ promoting session: %@", self.tag, sessionStateToPromote);
309310
[[sessionRecord previousSessionStates] removeObjectAtIndex:stateToPromoteIdx];
310311
[sessionRecord promoteState:sessionStateToPromote];
311312

@@ -314,7 +315,7 @@ - (NSData *)throws_decryptWithSessionRecord:(SessionRecord *)sessionRecord
314315

315316
BOOL containsActiveSession =
316317
[self.sessionStore containsSession:self.recipientId deviceId:self.deviceId protocolContext:protocolContext];
317-
DDLogError(@"%@ No valid session for recipient: %@.%lu containsActiveSession: %@, previousStates: %lu",
318+
OWSLogError(@"%@ No valid session for recipient: %@.%lu containsActiveSession: %@, previousStates: %lu",
318319
self.tag,
319320
self.recipientId,
320321
(unsigned long) self.deviceId,
@@ -386,10 +387,10 @@ - (ChainKey *)throws_getOrCreateChainKeys:(SessionState *)sessionState theirEphe
386387

387388
@try {
388389
if ([sessionState hasReceiverChain:theirEphemeral]) {
389-
DDLogInfo(@"%@ %@.%d has existing receiver chain.", self.tag, self.recipientId, self.deviceId);
390+
OWSLogInfo(@"%@ %@.%d has existing receiver chain.", self.tag, self.recipientId, self.deviceId);
390391
return [sessionState receiverChainKey:theirEphemeral];
391392
} else{
392-
DDLogInfo(@"%@ %@.%d creating new chains.", self.tag, self.recipientId, self.deviceId);
393+
OWSLogInfo(@"%@ %@.%d creating new chains.", self.tag, self.recipientId, self.deviceId);
393394
RootKey *rootKey = [sessionState rootKey];
394395
OWSAssert(rootKey.keyData.length == 32);
395396

0 commit comments

Comments
 (0)