From 44a3a81469bcf446f2f7e9804b971d7cacf5c214 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 4 Sep 2018 10:40:21 -0400 Subject: [PATCH] Update logging and asserts in hotfix changes. --- .../ConversationView/ConversationViewItem.m | 6 +++--- .../GifPicker/GifPickerCell.swift | 2 +- .../Messages/Attachments/TSAttachmentStream.m | 6 +++--- SignalServiceKit/src/Util/NSData+Image.m | 18 +++++++++--------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index e90e48dc9..de76ce925 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -482,7 +482,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) [self.attachmentStream isVideo]) { if ([self.attachmentStream isAnimated]) { if (![self.attachmentStream isValidImage]) { - DDLogWarn(@"Treating invalid image as generic attachment."); + OWSLogWarn(@"Treating invalid image as generic attachment."); self.messageCellType = OWSMessageCellType_GenericAttachment; return; } @@ -490,7 +490,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) self.messageCellType = OWSMessageCellType_AnimatedImage; } else if ([self.attachmentStream isImage]) { if (![self.attachmentStream isValidImage]) { - DDLogWarn(@"Treating invalid image as generic attachment."); + OWSLogWarn(@"Treating invalid image as generic attachment."); self.messageCellType = OWSMessageCellType_GenericAttachment; return; } @@ -498,7 +498,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) self.messageCellType = OWSMessageCellType_StillImage; } else if ([self.attachmentStream isVideo]) { if (![self.attachmentStream isValidVideo]) { - DDLogWarn(@"Treating invalid video as generic attachment."); + OWSLogWarn(@"Treating invalid video as generic attachment."); self.messageCellType = OWSMessageCellType_GenericAttachment; return; } diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift index 3cad84a21..c603a6336 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift @@ -197,7 +197,7 @@ class GifPickerCell: UICollectionViewCell { return } guard NSData.ows_isValidImage(atPath: asset.filePath, mimeType: OWSMimeTypeImageGif) else { - owsFail("\(logTag) invalid asset.") + owsFailDebug("invalid asset.") clearViewState() return } diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m index 4f645b96a..080b2c925 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m @@ -363,7 +363,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024; } if (![NSData ows_isValidImageAtPath:self.filePath mimeType:self.contentType]) { - OWSFail(@"%@ skipping invalid image", self.logTag); + OWSFailDebug(@"%@ skipping invalid image", self.logTag); return nil; } @@ -458,7 +458,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024; } else if (self.isVideo) { if (![self isValidVideo]) { - DDLogWarn(@"%@ skipping thumbnail for invalid video at path: %@", self.logTag, self.filePath); + OWSLogWarn(@"Skipping thumbnail for invalid video at path: %@", self.filePath); return; } @@ -507,7 +507,7 @@ const CGFloat kMaxVideoStillSize = 1 * 1024; CMTime time = CMTimeMake(1, 60); CGImageRef imgRef = [generator copyCGImageAtTime:time actualTime:NULL error:&err]; if (imgRef == NULL) { - DDLogError(@"Could not generate video still: %@", self.filePath.pathExtension); + OWSLogError(@"Could not generate video still: %@", self.filePath.pathExtension); return nil; } diff --git a/SignalServiceKit/src/Util/NSData+Image.m b/SignalServiceKit/src/Util/NSData+Image.m index d3422ae1c..e180b7bf2 100644 --- a/SignalServiceKit/src/Util/NSData+Image.m +++ b/SignalServiceKit/src/Util/NSData+Image.m @@ -49,7 +49,7 @@ typedef NS_ENUM(NSInteger, ImageFormat) { } if (![self ows_hasValidImageDimensionsAtPath:filePath]) { - DDLogError(@"%@ image had invalid dimensions.", self.logTag); + OWSLogError(@"image had invalid dimensions."); return NO; } @@ -96,14 +96,14 @@ typedef NS_ENUM(NSInteger, ImageFormat) { NSNumber *widthNumber = imageProperties[(__bridge NSString *)kCGImagePropertyPixelWidth]; if (!widthNumber) { - DDLogError(@"widthNumber was unexpectedly nil"); + OWSLogError(@"widthNumber was unexpectedly nil"); return NO; } CGFloat width = widthNumber.floatValue; NSNumber *heightNumber = imageProperties[(__bridge NSString *)kCGImagePropertyPixelHeight]; if (!heightNumber) { - DDLogError(@"heightNumber was unexpectedly nil"); + OWSLogError(@"heightNumber was unexpectedly nil"); return NO; } CGFloat height = heightNumber.floatValue; @@ -112,7 +112,7 @@ typedef NS_ENUM(NSInteger, ImageFormat) { * key is a CFNumberRef. */ NSNumber *depthNumber = imageProperties[(__bridge NSString *)kCGImagePropertyDepth]; if (!depthNumber) { - DDLogError(@"depthNumber was unexpectedly nil"); + OWSLogError(@"depthNumber was unexpectedly nil"); return NO; } NSUInteger depthBits = depthNumber.unsignedIntegerValue; @@ -122,12 +122,12 @@ typedef NS_ENUM(NSInteger, ImageFormat) { * The value of this key is CFStringRef. */ NSString *colorModel = imageProperties[(__bridge NSString *)kCGImagePropertyColorModel]; if (!colorModel) { - DDLogError(@"colorModel was unexpectedly nil"); + OWSLogError(@"colorModel was unexpectedly nil"); return NO; } if (![colorModel isEqualToString:(__bridge NSString *)kCGImagePropertyColorModelRGB] && ![colorModel isEqualToString:(__bridge NSString *)kCGImagePropertyColorModelGray]) { - DDLogError(@"Invalid colorModel: %@", colorModel); + OWSLogError(@"Invalid colorModel: %@", colorModel); return NO; } @@ -140,7 +140,7 @@ typedef NS_ENUM(NSInteger, ImageFormat) { CGFloat kMaxBytes = kMaxDimension * kMaxDimension * kExpectedBytePerPixel; CGFloat actualBytes = width * height * bytesPerPixel; if (actualBytes > kMaxBytes) { - DDLogWarn(@"invalid dimensions width: %f, height %f, bytesPerPixel: %f", width, height, bytesPerPixel); + OWSLogWarn(@"invalid dimensions width: %f, height %f, bytesPerPixel: %f", width, height, bytesPerPixel); return NO; } @@ -273,12 +273,12 @@ typedef NS_ENUM(NSInteger, ImageFormat) { maxSize.height = MAX(maxSize.height, trackSize.height); } if (maxSize.width < 1.f || maxSize.height < 1.f) { - DDLogError(@"Invalid video size: %@", NSStringFromCGSize(maxSize)); + OWSLogError(@"Invalid video size: %@", NSStringFromCGSize(maxSize)); return NO; } const CGFloat kMaxSize = 3 * 1024.f; if (maxSize.width > kMaxSize || maxSize.height > kMaxSize) { - DDLogError(@"Invalid video dimensions: %@", NSStringFromCGSize(maxSize)); + OWSLogError(@"Invalid video dimensions: %@", NSStringFromCGSize(maxSize)); return NO; } return YES;