Skip to content

Commit 00b32db

Browse files
authored
more debug logging (#29100)
1 parent 9276ad0 commit 00b32db

3 files changed

Lines changed: 131 additions & 65 deletions

File tree

go/bind/keybase.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@ func noteReadError(c net.Conn, err error) {
118118
}
119119
}
120120

121-
// log writes to kbCtx.Log if available, otherwise falls back to fmt.Printf
121+
// log writes to kbCtx.Log if available, otherwise falls back to stderr.
122+
// Stderr is captured in crash logs and the Xcode console, making early Init
123+
// messages (before kbCtx.Log is set up by Configure) visible in diagnostics.
122124
func log(format string, args ...interface{}) {
123125
msg := fmt.Sprintf(format, args...)
124126
if kbCtx != nil && kbCtx.Log != nil {
125127
kbCtx.Log.Info(msg)
126128
} else {
127-
fmt.Printf("%s\n", msg)
129+
fmt.Fprintf(os.Stderr, "keybase: %s\n", msg)
128130
}
129131
}
130132

rnmodules/react-native-kb/ios/Kb.mm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import <React/RCTCallInvoker.h>
1212
#import <UIKit/UIKit.h>
1313
#import <UserNotifications/UserNotifications.h>
14+
#import <os/log.h>
1415
#import <cstring>
1516
#include <atomic>
1617
#import <jsi/jsi.h>
@@ -395,11 +396,11 @@ - (NSDictionary *)getConstants {
395396
}
396397
if (consecutiveErrors <= 5 || consecutiveErrors % 50 == 0) {
397398
__typeof__(self) strongSelf = weakSelf;
398-
NSLog(@"ReadArr loop[%llu] error streak=%llu total=%llu domain=%s code=%ld desc=%s self=%p bridge=%p jsRuntime=%p currentRuntime=%p",
399-
(unsigned long long)readLoopGen, (unsigned long long)consecutiveErrors,
400-
(unsigned long long)totalErrors, KBStringOrNil(error.domain), (long)error.code,
401-
KBStringOrNil(error.localizedDescription), strongSelf, strongSelf.bridge,
402-
strongSelf ? [strongSelf javaScriptRuntimePointer] : nil, currentRuntime);
399+
os_log(OS_LOG_DEFAULT, "ReadArr loop[%llu] error streak=%llu total=%llu domain=%{public}s code=%ld desc=%{public}s self=%p bridge=%p jsRuntime=%p currentRuntime=%p",
400+
(unsigned long long)readLoopGen, (unsigned long long)consecutiveErrors,
401+
(unsigned long long)totalErrors, KBStringOrNil(error.domain), (long)error.code,
402+
KBStringOrNil(error.localizedDescription), strongSelf, strongSelf.bridge,
403+
strongSelf ? [strongSelf javaScriptRuntimePointer] : nil, currentRuntime);
403404
}
404405
// Back off on error to avoid spinning at ~35K/sec and starving the main thread CPU
405406
// during foreground re-entry (seen during hang investigation: 419K errors in 12s).

0 commit comments

Comments
 (0)