Skip to content

Commit 4900f98

Browse files
committed
fix: symbol loader log to system console to not confuse terminal output
1 parent b12d552 commit 4900f98

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

NativeScript/runtime/SymbolLoader.mm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
#include "SymbolLoader.h"
33
#include "Helpers.h"
44
#include <dlfcn.h>
5+
#include <os/log.h>
56

67
namespace tns {
78

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+
816
class SymbolResolver {
917
public:
1018
virtual void* loadFunctionSymbol(const char* symbolName) = 0;
@@ -101,7 +109,7 @@ virtual bool load() override {
101109
if (CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)bundleUrl)) {
102110
resolver = std::make_unique<CFBundleSymbolResolver>(bundle);
103111
} else {
104-
NSLog(@"NativeScript could not load bundle %s\n", bundleUrl.absoluteString.UTF8String);
112+
os_log_error(ns_symbolloader_log(), "NativeScript could not load bundle %{public}s", bundleUrl.absoluteString.UTF8String);
105113
}
106114
} else if (module->libraries->count == 1) {
107115
if (module->isSystem()) {
@@ -110,10 +118,10 @@ virtual bool load() override {
110118
NSString* libraryPath = [NSString stringWithFormat:@"%@/lib%s.dylib", libsPath, module->libraries->first()->value().getName()];
111119

112120
if (void* library = dlopen(libraryPath.UTF8String, RTLD_LAZY | RTLD_LOCAL)) {
113-
NSLog(@"NativeScript loaded library %s\n", libraryPath.UTF8String);
121+
os_log_info(ns_symbolloader_log(), "NativeScript loaded library %{public}s", libraryPath.UTF8String);
114122
resolver = std::make_unique<DlSymbolResolver>(library);
115123
} else if (const char* libraryError = dlerror()) {
116-
NSLog(@"NativeScript could not load library %s, error: %s\n", libraryPath.UTF8String, libraryError);
124+
os_log_error(ns_symbolloader_log(), "NativeScript could not load library %{public}s, error: %{public}s", libraryPath.UTF8String, libraryError);
117125
}
118126
}
119127
}

0 commit comments

Comments
 (0)