Skip to content

Commit

Permalink
Remove iOS 8 support from logging code. (TextureGroup#1462)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlai-Holler authored and hebertialmeida committed May 10, 2019
1 parent 68a16b2 commit 601d4e2
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 76 deletions.
8 changes: 4 additions & 4 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath
if ([self.collectionViewLayout isKindOfClass:[ASCollectionLayout class]]) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
as_log_debug(ASCollectionLog(), "Collection node item interactive movement is not supported when using a layout delegate. This message will only be logged once. Node: %@", ASObjectDescriptionMakeTiny(self));
os_log_debug(ASCollectionLog(), "Collection node item interactive movement is not supported when using a layout delegate. This message will only be logged once. Node: %@", ASObjectDescriptionMakeTiny(self));
});
return NO;
}
Expand Down Expand Up @@ -1877,7 +1877,7 @@ - (void)_beginBatchFetching
if (_asyncDelegateFlags.collectionNodeWillBeginBatchFetch) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
GET_COLLECTIONNODE_OR_RETURN(collectionNode, (void)0);
as_log_debug(ASCollectionLog(), "Beginning batch fetch for %@ with context %@", collectionNode, _batchContext);
os_log_debug(ASCollectionLog(), "Beginning batch fetch for %@ with context %@", collectionNode, _batchContext);
[_asyncDelegate collectionNode:collectionNode willBeginBatchFetchWithContext:_batchContext];
});
} else if (_asyncDelegateFlags.collectionViewWillBeginBatchFetch) {
Expand Down Expand Up @@ -2253,7 +2253,7 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet
_superIsPendingDataLoad = YES;
updates();
[self _superReloadData:nil completion:nil];
as_log_debug(ASCollectionLog(), "Did reloadData %@", self.collectionNode);
os_log_debug(ASCollectionLog(), "Did reloadData %@", self.collectionNode);
[changeSet executeCompletionHandlerWithFinished:YES];
} else {
[_layoutFacilitator collectionViewWillPerformBatchUpdates];
Expand Down Expand Up @@ -2315,7 +2315,7 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet
} completion:completion];
}

as_log_debug(ASCollectionLog(), "Completed batch update %{public}@", self.collectionNode);
os_log_debug(ASCollectionLog(), "Completed batch update %{public}@", self.collectionNode);

// Flush any range changes that happened as part of submitting the update.
as_activity_scope(changeSet.rootActivity);
Expand Down
2 changes: 1 addition & 1 deletion Source/ASDisplayNode+Layout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ - (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize
{
ASDisplayNodeAssertMainThread();
as_activity_create_for_scope("Transition node layout");
as_log_debug(ASLayoutLog(), "Transition layout for %@ sizeRange %@ anim %d asyncMeasure %d", self, NSStringFromASSizeRange(constrainedSize), animated, shouldMeasureAsync);
os_log_debug(ASLayoutLog(), "Transition layout for %@ sizeRange %@ anim %d asyncMeasure %d", self, NSStringFromASSizeRange(constrainedSize), animated, shouldMeasureAsync);

if (constrainedSize.max.width <= 0.0 || constrainedSize.max.height <= 0.0) {
// Using CGSizeZero for the sizeRange can cause negative values in client layout code.
Expand Down
2 changes: 1 addition & 1 deletion Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ - (void)__layout
// Performing layout on a zero-bounds view often results in frame calculations
// with negative sizes after applying margins, which will cause
// layoutThatFits: on subnodes to assert.
as_log_debug(OS_LOG_DISABLED, "Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self);
os_log_debug(OS_LOG_DISABLED, "Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/ASMainThreadDeallocation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ - (void)scheduleIvarsForMainThreadDeallocation
}

if ([object_getClass(value) needsMainThreadDeallocation]) {
as_log_debug(ASMainThreadDeallocationLog(), "%@: Trampolining ivar '%s' value %@ for main deallocation.", self, ivar_getName(ivar), value);
os_log_debug(ASMainThreadDeallocationLog(), "%@: Trampolining ivar '%s' value %@ for main deallocation.", self, ivar_getName(ivar), value);

// Release the ivar's reference before handing the object to the queue so we
// don't risk holding onto it longer than the queue does.
object_setIvar(self, ivar, nil);

ASPerformMainThreadDeallocation(&value);
} else {
as_log_debug(ASMainThreadDeallocationLog(), "%@: Not trampolining ivar '%s' value %@.", self, ivar_getName(ivar), value);
os_log_debug(ASMainThreadDeallocationLog(), "%@: Not trampolining ivar '%s' value %@.", self, ivar_getName(ivar), value);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/ASMultiplexImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ - (void)_loadNextImage
NSURL *nextImageURL = (_dataSourceFlags.URL) ? [_dataSource multiplexImageNode:self URLForImageIdentifier:nextImageIdentifier] : nil;
// If we fail to get a URL for the image, we have no source and can't proceed.
if (!nextImageURL) {
as_log_error(ASImageLoadingLog(), "Could not acquire URL %@ ident: (%@)", self, nextImageIdentifier);
os_log_error(ASImageLoadingLog(), "Could not acquire URL %@ ident: (%@)", self, nextImageIdentifier);
finishedLoadingBlock(nil, nil, [NSError errorWithDomain:ASMultiplexImageNodeErrorDomain code:ASMultiplexImageNodeErrorCodeNoSourceForImage userInfo:nil]);
return;
}
Expand Down Expand Up @@ -684,7 +684,7 @@ - (void)_loadNextImage
if (downloadedImage) {
as_log_verbose(ASImageLoadingLog(), "Acquired image from download for %@ id: %@ img: %@", strongSelf, nextImageIdentifier, downloadedImage);
} else {
as_log_error(ASImageLoadingLog(), "Error downloading image for %@ id: %@ err: %@", strongSelf, nextImageIdentifier, error);
os_log_error(ASImageLoadingLog(), "Error downloading image for %@ id: %@ err: %@", strongSelf, nextImageIdentifier, error);
}
finishedLoadingBlock(downloadedImage, nextImageIdentifier, error);
}];
Expand Down
10 changes: 5 additions & 5 deletions Source/ASNavigationController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BO
{
as_activity_create_for_scope("Pop multiple from ASNavigationController");
NSArray *viewControllers = [super popToViewController:viewController animated:animated];
as_log_info(ASNodeLog(), "Popped %@ to %@, removing %@", self, viewController, ASGetDescriptionValueString(viewControllers));
os_log_info(ASNodeLog(), "Popped %@ to %@, removing %@", self, viewController, ASGetDescriptionValueString(viewControllers));

[self visibilityDepthDidChange];
return viewControllers;
Expand All @@ -71,7 +71,7 @@ - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
{
as_activity_create_for_scope("Pop to root of ASNavigationController");
NSArray *viewControllers = [super popToRootViewControllerAnimated:animated];
as_log_info(ASNodeLog(), "Popped view controllers %@ from %@", ASGetDescriptionValueString(viewControllers), self);
os_log_info(ASNodeLog(), "Popped view controllers %@ from %@", ASGetDescriptionValueString(viewControllers), self);

[self visibilityDepthDidChange];
return viewControllers;
Expand All @@ -88,15 +88,15 @@ - (void)setViewControllers:(NSArray *)viewControllers
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
{
as_activity_create_for_scope("Set view controllers of ASNavigationController");
as_log_info(ASNodeLog(), "Set view controllers of %@ to %@ animated: %d", self, ASGetDescriptionValueString(viewControllers), animated);
os_log_info(ASNodeLog(), "Set view controllers of %@ to %@ animated: %d", self, ASGetDescriptionValueString(viewControllers), animated);
[super setViewControllers:viewControllers animated:animated];
[self visibilityDepthDidChange];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
as_activity_create_for_scope("Push view controller on ASNavigationController");
as_log_info(ASNodeLog(), "Pushing %@ onto %@", viewController, self);
os_log_info(ASNodeLog(), "Pushing %@ onto %@", viewController, self);
[super pushViewController:viewController animated:animated];
[self visibilityDepthDidChange];
}
Expand All @@ -105,7 +105,7 @@ - (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
as_activity_create_for_scope("Pop view controller from ASNavigationController");
UIViewController *viewController = [super popViewControllerAnimated:animated];
as_log_info(ASNodeLog(), "Popped %@ from %@", viewController, self);
os_log_info(ASNodeLog(), "Popped %@ from %@", viewController, self);
[self visibilityDepthDidChange];
return viewController;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/ASTabBarController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ - (void)setViewControllers:(NSArray<__kindof UIViewController *> *)viewControlle
- (void)setSelectedIndex:(NSUInteger)selectedIndex
{
as_activity_create_for_scope("Set selected index of ASTabBarController");
as_log_info(ASNodeLog(), "Selected tab %tu of %@", selectedIndex, self);
os_log_info(ASNodeLog(), "Selected tab %tu of %@", selectedIndex, self);

[super setSelectedIndex:selectedIndex];
[self visibilityDepthDidChange];
Expand All @@ -75,7 +75,7 @@ - (void)setSelectedIndex:(NSUInteger)selectedIndex
- (void)setSelectedViewController:(__kindof UIViewController *)selectedViewController
{
as_activity_create_for_scope("Set selected view controller of ASTabBarController");
as_log_info(ASNodeLog(), "Selected view controller %@ of %@", selectedViewController, self);
os_log_info(ASNodeLog(), "Selected view controller %@ of %@", selectedViewController, self);

[super setSelectedViewController:selectedViewController];
[self visibilityDepthDidChange];
Expand Down
4 changes: 2 additions & 2 deletions Source/ASViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ - (void)_updateNodeFallbackSafeArea
- (void)viewWillAppear:(BOOL)animated
{
as_activity_create_for_scope("ASViewController will appear");
as_log_debug(ASNodeLog(), "View controller %@ will appear", self);
os_log_debug(ASNodeLog(), "View controller %@ will appear", self);

[super viewWillAppear:animated];

Expand Down Expand Up @@ -325,7 +325,7 @@ - (void)propagateNewTraitCollection:(ASPrimitiveTraitCollection)traitCollection

if (ASPrimitiveTraitCollectionIsEqualToASPrimitiveTraitCollection(traitCollection, oldTraitCollection) == NO) {
as_activity_scope_verbose(as_activity_create("Propagate ASViewController trait collection", AS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT));
as_log_debug(ASNodeLog(), "Propagating new traits for %@: %@", self, NSStringFromASPrimitiveTraitCollection(traitCollection));
os_log_debug(ASNodeLog(), "Propagating new traits for %@: %@", self, NSStringFromASPrimitiveTraitCollection(traitCollection));
ASTraitCollectionPropagateDown(self.node, traitCollection);

// Once we've propagated all the traits, layout this node.
Expand Down
45 changes: 1 addition & 44 deletions Source/Base/ASLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,51 +119,8 @@ AS_EXTERN os_log_t ASLockingLog(void);
#define as_activity_create_for_scope(description) \
as_activity_scope(as_activity_create(description, AS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT))

/**
* The logging macros are not guarded by deployment-target checks like the activity macros are, but they are
* only available on iOS >= 9 at runtime, so just make them conditional.
*/

#define as_log_create(subsystem, category) ({ \
os_log_t __val; \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
__val = os_log_create(subsystem, category); \
} else { \
__val = (os_log_t)0; \
} \
__val; \
})

#define as_log_debug(log, format, ...) \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_debug(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
} \

#define as_log_info(log, format, ...) \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_info(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
} \

#define as_log_error(log, format, ...) \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_error(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
} \

#define as_log_fault(log, format, ...) \
if (AS_AVAILABLE_IOS_TVOS(9, 9)) { \
os_log_fault(log, format, ##__VA_ARGS__); \
} else { \
(void)0; \
} \

#if ASEnableVerboseLogging
#define as_log_verbose(log, format, ...) as_log_debug(log, format, ##__VA_ARGS__)
#define as_log_verbose(log, format, ...) os_log_debug(log, format, ##__VA_ARGS__)
#else
#define as_log_verbose(log, format, ...)
#endif
14 changes: 7 additions & 7 deletions Source/Base/ASLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ ASDISPLAYNODE_INLINE BOOL ASLoggingIsEnabled() {
}

os_log_t ASNodeLog() {
return (ASNodeLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(as_log_create("org.TextureGroup.Texture", "Node")) : OS_LOG_DISABLED;
return (ASNodeLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(os_log_create("org.TextureGroup.Texture", "Node")) : OS_LOG_DISABLED;
}

os_log_t ASLayoutLog() {
return (ASLayoutLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(as_log_create("org.TextureGroup.Texture", "Layout")) : OS_LOG_DISABLED;
return (ASLayoutLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(os_log_create("org.TextureGroup.Texture", "Layout")) : OS_LOG_DISABLED;
}

os_log_t ASCollectionLog() {
return (ASCollectionLogEnabled && ASLoggingIsEnabled()) ?ASCreateOnce(as_log_create("org.TextureGroup.Texture", "Collection")) : OS_LOG_DISABLED;
return (ASCollectionLogEnabled && ASLoggingIsEnabled()) ?ASCreateOnce(os_log_create("org.TextureGroup.Texture", "Collection")) : OS_LOG_DISABLED;
}

os_log_t ASDisplayLog() {
return (ASDisplayLogEnabled && ASLoggingIsEnabled()) ?ASCreateOnce(as_log_create("org.TextureGroup.Texture", "Display")) : OS_LOG_DISABLED;
return (ASDisplayLogEnabled && ASLoggingIsEnabled()) ?ASCreateOnce(os_log_create("org.TextureGroup.Texture", "Display")) : OS_LOG_DISABLED;
}

os_log_t ASImageLoadingLog() {
return (ASImageLoadingLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(as_log_create("org.TextureGroup.Texture", "ImageLoading")) : OS_LOG_DISABLED;
return (ASImageLoadingLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(os_log_create("org.TextureGroup.Texture", "ImageLoading")) : OS_LOG_DISABLED;
}

os_log_t ASMainThreadDeallocationLog() {
return (ASMainThreadDeallocationLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(as_log_create("org.TextureGroup.Texture", "MainDealloc")) : OS_LOG_DISABLED;
return (ASMainThreadDeallocationLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(os_log_create("org.TextureGroup.Texture", "MainDealloc")) : OS_LOG_DISABLED;
}

os_log_t ASLockingLog() {
return (ASLockingLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(as_log_create("org.TextureGroup.Texture", "Locking")) : OS_LOG_DISABLED;
return (ASLockingLogEnabled && ASLoggingIsEnabled()) ? ASCreateOnce(os_log_create("org.TextureGroup.Texture", "Locking")) : OS_LOG_DISABLED;
}
2 changes: 1 addition & 1 deletion Source/Details/ASBatchContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)beginBatchFetching
- (void)completeBatchFetching:(BOOL)didComplete
{
if (didComplete) {
as_log_debug(ASCollectionLog(), "Completed batch fetch with context %@", self);
os_log_debug(ASCollectionLog(), "Completed batch fetch with context %@", self);
atomic_store(&_state, ASBatchContextStateCompleted);
}
}
Expand Down
10 changes: 5 additions & 5 deletions Source/Details/ASDataController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,13 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet

if (changeSet.includesReloadData) {
if (_initialReloadDataHasBeenCalled) {
as_log_debug(ASCollectionLog(), "reloadData %@", ASViewToDisplayNode(ASDynamicCast(self.dataSource, UIView)));
os_log_debug(ASCollectionLog(), "reloadData %@", ASViewToDisplayNode(ASDynamicCast(self.dataSource, UIView)));
} else {
as_log_debug(ASCollectionLog(), "Initial reloadData %@", ASViewToDisplayNode(ASDynamicCast(self.dataSource, UIView)));
os_log_debug(ASCollectionLog(), "Initial reloadData %@", ASViewToDisplayNode(ASDynamicCast(self.dataSource, UIView)));
_initialReloadDataHasBeenCalled = YES;
}
} else {
as_log_debug(ASCollectionLog(), "performBatchUpdates %@ %@", ASViewToDisplayNode(ASDynamicCast(self.dataSource, UIView)), changeSet);
os_log_debug(ASCollectionLog(), "performBatchUpdates %@ %@", ASViewToDisplayNode(ASDynamicCast(self.dataSource, UIView)), changeSet);
}

NSTimeInterval transactionQueueFlushDuration = 0.0f;
Expand All @@ -575,7 +575,7 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet
// See ASUICollectionViewTests.testThatIssuingAnUpdateBeforeInitialReloadIsUnacceptable
// for the issue that UICollectionView has that we're choosing to workaround.
if (!_initialReloadDataHasBeenCalled) {
as_log_debug(ASCollectionLog(), "%@ Skipped update because load hasn't happened.", ASObjectDescriptionMakeTiny(_dataSource));
os_log_debug(ASCollectionLog(), "%@ Skipped update because load hasn't happened.", ASObjectDescriptionMakeTiny(_dataSource));
[changeSet executeCompletionHandlerWithFinished:YES];
return;
}
Expand Down Expand Up @@ -639,7 +639,7 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet
}
}

as_log_debug(ASCollectionLog(), "New content: %@", newMap.smallDescription);
os_log_debug(ASCollectionLog(), "New content: %@", newMap.smallDescription);

Class<ASDataControllerLayoutDelegate> layoutDelegateClass = [self.layoutDelegate class];
++_editingTransactionGroupCount;
Expand Down

0 comments on commit 601d4e2

Please sign in to comment.