mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Add a macro (default 0) to control event backtrace recording (#2584)
This commit is contained in:
parent
9385425d07
commit
6bbc9a3cb0
@ -20,7 +20,7 @@ void ASPerformBlockOnBackgroundThread(void (^block)()); // DISPATCH_QUEUE_PRIORI
|
|||||||
ASDISPLAYNODE_EXTERN_C_END
|
ASDISPLAYNODE_EXTERN_C_END
|
||||||
|
|
||||||
#if ASEVENTLOG_ENABLE
|
#if ASEVENTLOG_ENABLE
|
||||||
#define ASDisplayNodeLogEvent(node, ...) [node.eventLog logEventWithBacktrace:[NSThread callStackSymbols] format:__VA_ARGS__]
|
#define ASDisplayNodeLogEvent(node, ...) [node.eventLog logEventWithBacktrace:(AS_SAVE_EVENT_BACKTRACES ? [NSThread callStackSymbols] : nil) format:__VA_ARGS__]
|
||||||
#else
|
#else
|
||||||
#define ASDisplayNodeLogEvent(node, ...)
|
#define ASDisplayNodeLogEvent(node, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
#if ASEVENTLOG_ENABLE
|
#if ASEVENTLOG_ENABLE
|
||||||
#define ASDataControllerLogEvent(dataController, ...) [dataController.eventLog logEventWithBacktrace:[NSThread callStackSymbols] format:__VA_ARGS__]
|
#define ASDataControllerLogEvent(dataController, ...) [dataController.eventLog logEventWithBacktrace:(AS_SAVE_EVENT_BACKTRACES ? [NSThread callStackSymbols] : nil) format:__VA_ARGS__]
|
||||||
#else
|
#else
|
||||||
#define ASDataControllerLogEvent(dataController, ...)
|
#define ASDataControllerLogEvent(dataController, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -18,8 +18,12 @@
|
|||||||
#define ASEVENTLOG_ENABLE 1
|
#define ASEVENTLOG_ENABLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface ASEventLog : NSObject
|
@interface ASEventLog : NSObject
|
||||||
|
|
||||||
- (void)logEventWithBacktrace:(NSArray<NSString *> *)backtrace format:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3);
|
- (void)logEventWithBacktrace:(nullable NSArray<NSString *> *)backtrace format:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3);
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
@ -8,18 +8,23 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface ASTraceEvent : NSObject
|
@interface ASTraceEvent : NSObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is dealloc safe.
|
* This method is dealloc safe.
|
||||||
*/
|
*/
|
||||||
- (instancetype)initWithObject:(id)object
|
- (instancetype)initWithObject:(id)object
|
||||||
backtrace:(NSArray<NSString *> *)backtrace
|
backtrace:(nullable NSArray<NSString *> *)backtrace
|
||||||
format:(NSString *)format
|
format:(NSString *)format
|
||||||
arguments:(va_list)arguments NS_FORMAT_FUNCTION(3,0);
|
arguments:(va_list)arguments NS_FORMAT_FUNCTION(3,0);
|
||||||
|
|
||||||
@property (nonatomic, readonly) NSArray<NSString *> *backtrace;
|
// Will be nil unless AS_SAVE_EVENT_BACKTRACES=1 (default=0)
|
||||||
|
@property (nonatomic, nullable, readonly) NSArray<NSString *> *backtrace;
|
||||||
@property (nonatomic, strong, readonly) NSString *message;
|
@property (nonatomic, strong, readonly) NSString *message;
|
||||||
@property (nonatomic, readonly) NSTimeInterval timestamp;
|
@property (nonatomic, readonly) NSTimeInterval timestamp;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
@ -46,9 +46,7 @@
|
|||||||
}
|
}
|
||||||
_threadDescription = threadDescription;
|
_threadDescription = threadDescription;
|
||||||
|
|
||||||
// The backtrace will be an _NSCallStackArray which is actually pretty
|
_backtrace = backtrace;
|
||||||
// huge and retains other objects. Create an immutable NSArray<NSString *> from it.
|
|
||||||
_backtrace = [[NSArray alloc] initWithArray:backtrace];
|
|
||||||
_timestamp = CACurrentMediaTime() - refTime;
|
_timestamp = CACurrentMediaTime() - refTime;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
|||||||
@ -96,6 +96,17 @@
|
|||||||
# define ASDISPLAYNODE_NOTHROW
|
# define ASDISPLAYNODE_NOTHROW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The event backtraces take a static 2KB of memory
|
||||||
|
* and retain all objects present in all the registers
|
||||||
|
* of the stack frames. The memory consumption impact
|
||||||
|
* is too significant even to be enabled during general
|
||||||
|
* development.
|
||||||
|
*/
|
||||||
|
#ifndef AS_SAVE_EVENT_BACKTRACES
|
||||||
|
# define AS_SAVE_EVENT_BACKTRACES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ARRAY_COUNT(x) sizeof(x) / sizeof(x[0])
|
#define ARRAY_COUNT(x) sizeof(x) / sizeof(x[0])
|
||||||
|
|
||||||
#ifndef __has_feature // Optional.
|
#ifndef __has_feature // Optional.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user