[ASDisplayNode] Add Event Tracing to Help Debugging (#2243)

* Add some simple event logging for ASDisplayNode

Improve the tracing

* Add header to copy files phase

* Make event header public
This commit is contained in:
Adlai Holler
2016-09-15 13:24:19 -07:00
committed by GitHub
parent 8459c1e825
commit 25de53bb13
12 changed files with 315 additions and 27 deletions

View File

@@ -10,6 +10,7 @@
#import "ASDisplayNode.h"
#import "ASLayoutRangeType.h"
#import "ASTraceEvent.h"
NS_ASSUME_NONNULL_BEGIN
@@ -18,6 +19,20 @@ void ASPerformBlockOnMainThread(void (^block)());
void ASPerformBlockOnBackgroundThread(void (^block)()); // DISPATCH_QUEUE_PRIORITY_DEFAULT
ASDISPLAYNODE_EXTERN_C_END
#ifndef ASDISPLAYNODE_EVENTLOG_CAPACITY
#define ASDISPLAYNODE_EVENTLOG_CAPACITY 20
#endif
#ifndef ASDISPLAYNODE_EVENTLOG_ENABLE
#define ASDISPLAYNODE_EVENTLOG_ENABLE DEBUG
#endif
#if ASDISPLAYNODE_EVENTLOG_ENABLE
#define ASDisplayNodeLogEvent(node, ...) [node _logEventWithBacktrace:[NSThread callStackSymbols] format:__VA_ARGS__]
#else
#define ASDisplayNodeLogEvent(node, ...)
#endif
/**
* Bitmask to indicate what performance measurements the cell should record.
*/
@@ -110,6 +125,20 @@ extern NSString *const ASDisplayNodeLayoutGenerationNumberOfPassesKey;
*/
+ (void)setRangeModeForMemoryWarnings:(ASLayoutRangeMode)rangeMode;
#if ASDISPLAYNODE_EVENTLOG_ENABLE
/**
* The primitive event tracing method. You shouldn't call this. Use the ASDisplayNodeLogEvent macro instead.
*/
- (void)_logEventWithBacktrace:(NSArray<NSString *> *)backtrace format:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3);
/**
* @abstract The most recent trace events for this node. Max count is ASDISPLAYNODE_EVENTLOG_CAPACITY.
*/
@property (readonly, copy) NSArray *eventLog;
#endif
@end
NS_ASSUME_NONNULL_END