11#include " SymbolLoader.h"
22#include < Foundation/Foundation.h>
33#include < dlfcn.h>
4- #include " Helpers.h "
4+ #include < os/log.h >
55
66namespace tns {
77
8+ // Unified logging: create a dedicated log for the SymbolLoader
9+ static os_log_t ns_symbolloader_log () {
10+ // Function-local static initialization is thread-safe in C++11+.
11+ static os_log_t log = os_log_create (" @nativescript/ios" , " SymbolLoader" );
12+ return log;
13+ }
14+
815class SymbolResolver {
916 public:
1017 virtual void * loadFunctionSymbol (const char * symbolName) = 0;
@@ -37,7 +44,7 @@ virtual bool load() override {
3744 CFErrorRef error = nullptr ;
3845 bool loaded = CFBundleLoadExecutableAndReturnError (this ->_bundle , &error);
3946 if (error) {
40- Log ( " % s" , [[(NSError *)error localizedDescription ] UTF8String ]);
47+ os_log_error ( ns_symbolloader_log (), " %{public} s" , [[(NSError *)error localizedDescription ] UTF8String ]);
4148 }
4249
4350 return loaded;
@@ -101,8 +108,6 @@ virtual bool load() override {
101108 NSURL * bundleUrl = [NSURL URLWithString: frameworkPathStr relativeToURL: baseUrl];
102109 if (CFBundleRef bundle = CFBundleCreate (kCFAllocatorDefault , (CFURLRef)bundleUrl)) {
103110 resolver = std::make_unique<CFBundleSymbolResolver>(bundle);
104- } else {
105- Log (" NativeScript could not load bundle %s" , bundleUrl.absoluteString .UTF8String );
106111 }
107112 } else if (module ->libraries ->count == 1 ) {
108113 if (module ->isSystem ()) {
@@ -113,11 +118,9 @@ virtual bool load() override {
113118 module ->libraries->first ()->value ().getName ()];
114119
115120 if (void * library = dlopen (libraryPath.UTF8String , RTLD_LAZY | RTLD_LOCAL)) {
116- Log (" NativeScript loaded library %s" , libraryPath.UTF8String );
117121 resolver = std::make_unique<DlSymbolResolver>(library);
118122 } else if (const char * libraryError = dlerror ()) {
119- Log (" NativeScript could not load library %s, error: %s" , libraryPath.UTF8String ,
120- libraryError);
123+ os_log_debug (ns_symbolloader_log (), " NativeScript could not load library %{public}s, error: %{public}s" , libraryPath.UTF8String , libraryError);
121124 }
122125 }
123126 }
0 commit comments