2
2
#include " SymbolLoader.h"
3
3
#include " Helpers.h"
4
4
#include < dlfcn.h>
5
+ #include < os/log.h>
5
6
6
7
namespace tns {
7
8
9
+ // Unified logging: create a dedicated log for the SymbolLoader
10
+ static os_log_t ns_symbolloader_log () {
11
+ // Function-local static initialization is thread-safe in C++11+.
12
+ static os_log_t log = os_log_create (" @nativescript/ios" , " SymbolLoader" );
13
+ return log;
14
+ }
15
+
8
16
class SymbolResolver {
9
17
public:
10
18
virtual void * loadFunctionSymbol (const char * symbolName) = 0;
@@ -35,7 +43,7 @@ virtual bool load() override {
35
43
CFErrorRef error = nullptr ;
36
44
bool loaded = CFBundleLoadExecutableAndReturnError (this ->_bundle , &error);
37
45
if (error) {
38
- NSLog ( @" % s" , [[(NSError *)error localizedDescription ] UTF8String ]);
46
+ os_log_error ( ns_symbolloader_log (), " %{public} s" , [[(NSError *)error localizedDescription ] UTF8String ]);
39
47
}
40
48
41
49
return loaded;
@@ -100,8 +108,6 @@ virtual bool load() override {
100
108
NSURL * bundleUrl = [NSURL URLWithString: frameworkPathStr relativeToURL: baseUrl];
101
109
if (CFBundleRef bundle = CFBundleCreate (kCFAllocatorDefault , (CFURLRef)bundleUrl)) {
102
110
resolver = std::make_unique<CFBundleSymbolResolver>(bundle);
103
- } else {
104
- NSLog (@" NativeScript could not load bundle %s \n " , bundleUrl.absoluteString.UTF8String);
105
111
}
106
112
} else if (module ->libraries ->count == 1 ) {
107
113
if (module ->isSystem ()) {
@@ -110,10 +116,9 @@ virtual bool load() override {
110
116
NSString * libraryPath = [NSString stringWithFormat: @" %@ /lib%s .dylib" , libsPath, module ->libraries->first ()->value ().getName ()];
111
117
112
118
if (void * library = dlopen (libraryPath.UTF8String , RTLD_LAZY | RTLD_LOCAL)) {
113
- NSLog (@" NativeScript loaded library %s \n " , libraryPath.UTF8String);
114
119
resolver = std::make_unique<DlSymbolResolver>(library);
115
120
} else if (const char * libraryError = dlerror ()) {
116
- NSLog ( @ " NativeScript could not load library %s , error: %s \n " , libraryPath.UTF8String, libraryError);
121
+ os_log_debug ( ns_symbolloader_log (), " NativeScript could not load library %{public} s, error: %{public}s " , libraryPath.UTF8String , libraryError);
117
122
}
118
123
}
119
124
}
0 commit comments