File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ @implementation NSLogHook
1919
2020static void (*orig_nslog)(NSString *format, ...);
2121
22+
2223void my_nslog (NSString *format, ...) {
2324 /* 方法一*/
2425// va_list vl;
@@ -40,9 +41,15 @@ void my_nslog(NSString *format, ...) {
4041 va_end (va);
4142}
4243
44+
4345+ (void )load {
44- struct rebinding nslog_rebinding = {" NSLog" ,my_nslog,(void *)&orig_nslog};
45- rebind_symbols ((struct rebinding[1 ]){nslog_rebinding}, 1 );
46+ if (![[NSUserDefaults standardUserDefaults ] boolForKey: @" disableLogMonitoring_CocoaDebug" ]) {
47+ static dispatch_once_t onceToken;
48+ dispatch_once (&onceToken, ^{
49+ struct rebinding nslog_rebinding = {" NSLog" ,my_nslog,(void *)&orig_nslog};
50+ rebind_symbols ((struct rebinding[1 ]){nslog_rebinding}, 1 );
51+ });
52+ }
4653}
4754
4855@end
You can’t perform that action at this time.
0 commit comments