diff --git a/NativeScript/runtime/SymbolLoader.mm b/NativeScript/runtime/SymbolLoader.mm index cd67b7b1..66672b55 100644 --- a/NativeScript/runtime/SymbolLoader.mm +++ b/NativeScript/runtime/SymbolLoader.mm @@ -2,9 +2,17 @@ #include "SymbolLoader.h" #include "Helpers.h" #include +#include namespace tns { +// Unified logging: create a dedicated log for the SymbolLoader +static os_log_t ns_symbolloader_log() { + // Function-local static initialization is thread-safe in C++11+. + static os_log_t log = os_log_create("@nativescript/ios", "SymbolLoader"); + return log; +} + class SymbolResolver { public: virtual void* loadFunctionSymbol(const char* symbolName) = 0; @@ -35,7 +43,7 @@ virtual bool load() override { CFErrorRef error = nullptr; bool loaded = CFBundleLoadExecutableAndReturnError(this->_bundle, &error); if (error) { - NSLog(@"%s", [[(NSError*)error localizedDescription] UTF8String]); + os_log_error(ns_symbolloader_log(), "%{public}s", [[(NSError*)error localizedDescription] UTF8String]); } return loaded; @@ -100,8 +108,6 @@ virtual bool load() override { NSURL* bundleUrl = [NSURL URLWithString:frameworkPathStr relativeToURL:baseUrl]; if (CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)bundleUrl)) { resolver = std::make_unique(bundle); - } else { - NSLog(@"NativeScript could not load bundle %s\n", bundleUrl.absoluteString.UTF8String); } } else if (module->libraries->count == 1) { if (module->isSystem()) { @@ -110,10 +116,9 @@ virtual bool load() override { NSString* libraryPath = [NSString stringWithFormat:@"%@/lib%s.dylib", libsPath, module->libraries->first()->value().getName()]; if (void* library = dlopen(libraryPath.UTF8String, RTLD_LAZY | RTLD_LOCAL)) { - NSLog(@"NativeScript loaded library %s\n", libraryPath.UTF8String); resolver = std::make_unique(library); } else if (const char* libraryError = dlerror()) { - NSLog(@"NativeScript could not load library %s, error: %s\n", libraryPath.UTF8String, libraryError); + os_log_debug(ns_symbolloader_log(), "NativeScript could not load library %{public}s, error: %{public}s", libraryPath.UTF8String, libraryError); } } }