- [console.js] global.console > getNativeLogFunction > global.nativeLoggingHook
- [JSCExecutorFactory.cpp] createJSExecutor > bindNativeLogger
- [RCTLog.mm] _RCTLogJavaScriptInternal -- 判断日志等级 RCTGetLogThreshold() --> RCTGetLocalLogFunction > RCTGetLogFunction
- [OnLoad.cpp] installBindings > bindNativeLogger > [JSCLogging.cpp] reactAndroidLoggingHook
打印日志函数
RCTLogFunction RCTDefaultLogFunction = ^(
RCTLogLevel level,
__unused RCTLogSource source,
NSString *fileName,
NSNumber *lineNumber,
NSString *message
)
{
NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message);
fprintf(stderr, "%s\n", log.UTF8String);
fflush(stderr);
};
assert 会抛异常
void RCTFatal(NSError *error)
{
@throw [[NSException alloc] initWithName:name reason:message userInfo:userInfo];
}
JS
iOS