diff --git a/framework/ios/base/modules/HippyModulesSetup.mm b/framework/ios/base/modules/HippyModulesSetup.mm index 79dc84cb8b2..c3496048045 100644 --- a/framework/ios/base/modules/HippyModulesSetup.mm +++ b/framework/ios/base/modules/HippyModulesSetup.mm @@ -176,7 +176,7 @@ - (void)setupModulesCompletion:(dispatch_block_t)completion { // Check for name collisions between preregistered modules HippyModuleData *moduleData = moduleDataByName[moduleName]; if (moduleData) { - HippyLogError(@"Attempted to register HippyBridgeModule class %@ for the " + HippyLogWarn(@"Attempted to register HippyBridgeModule class %@ for the " "name '%@', but name was already registered by class %@", moduleClass, moduleName, moduleData.moduleClass); continue; @@ -202,7 +202,7 @@ - (void)setupModulesCompletion:(dispatch_block_t)completion { continue; } else if ([moduleData.moduleClass new] != nil) { // Both modules were non-nil, so it's unclear which should take precedence - HippyLogError(@"Attempted to register HippyBridgeModule class %@ for the " + HippyLogWarn(@"Attempted to register HippyBridgeModule class %@ for the " "name '%@', but name was already registered by class %@", moduleClass, moduleName, moduleData.moduleClass); } diff --git a/framework/ios/utils/NSObject+CtxValue.mm b/framework/ios/utils/NSObject+CtxValue.mm index c33a8fb3082..430ce2cd496 100644 --- a/framework/ios/utils/NSObject+CtxValue.mm +++ b/framework/ios/utils/NSObject+CtxValue.mm @@ -22,7 +22,7 @@ #import "NSObject+CtxValue.h" #import "HippyAsserts.h" - +#import "HippyLog.h" #include "driver/napi/js_ctx.h" #include "driver/napi/js_ctx_value.h" #include "footstone/string_view.h" @@ -32,7 +32,7 @@ @implementation NSObject (CtxValue) - (CtxValuePtr)convertToCtxValue:(const CtxPtr &)context; { @autoreleasepool { - HippyAssert(NO, @"%@ must implemente convertToCtxValue method", NSStringFromClass([self class])); + HippyLogWarn(@"%@ must implemente convertToCtxValue method", NSStringFromClass([self class])); std::unordered_map valueMap; return context->CreateObject(valueMap); } diff --git a/modules/ios/base/HippyLog.mm b/modules/ios/base/HippyLog.mm index c2881036d49..96b1c3cb586 100644 --- a/modules/ios/base/HippyLog.mm +++ b/modules/ios/base/HippyLog.mm @@ -83,6 +83,20 @@ void HippyAddLogFunction(HippyLogFunction logFunction) { } } +/** + * returns the topmost stacked log function for the current thread, which + * may not be the same as the current value of HippyCurrentLogFunction. + */ +static HippyLogFunction HippyGetLocalLogFunction() { + NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; + NSArray *functionStack = threadDictionary[HippyLogFunctionStack]; + HippyLogFunction logFunction = functionStack.lastObject; + if (logFunction) { + return logFunction; + } + return HippyGetLogFunction(); +} + void HippyPerformBlockWithLogFunction(void (^block)(void), HippyLogFunction logFunction) { NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; NSMutableArray *functionStack = threadDictionary[HippyLogFunctionStack]; @@ -96,7 +110,7 @@ void HippyPerformBlockWithLogFunction(void (^block)(void), HippyLogFunction logF } void HippyPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix) { - HippyLogFunction logFunction = HippyGetLogFunction(); + HippyLogFunction logFunction = HippyGetLocalLogFunction(); if (logFunction) { HippyPerformBlockWithLogFunction(block, ^(HippyLogLevel level, HippyLogSource source, @@ -153,7 +167,7 @@ void HippyPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix) { } void HippyLogNativeInternal(HippyLogLevel level, const char *fileName, int lineNumber, NSString *format, ...) { - HippyLogFunction logFunction = HippyGetLogFunction(); + HippyLogFunction logFunction = HippyGetLocalLogFunction(); BOOL log = HIPPY_DEBUG || (logFunction != nil); if (log && level >= HippyGetLogThreshold()) { // Get message