Skip to content

Commit 575f145

Browse files
author
man.li
committed
no message
1 parent 40a16f8 commit 575f145

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Sources/Logs/_NSLogHook.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ @implementation NSLogHook
1919

2020
static void (*orig_nslog)(NSString *format, ...);
2121

22+
2223
void 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

0 commit comments

Comments
 (0)