Skip to content

Commit dabd7e9

Browse files
committed
[[ MCLog ]] Use NSLog for MCLog on macOS and iOS
1 parent d118bad commit dabd7e9

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

libfoundation/src/foundation-debug.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,33 @@ void __MCAssert(const char *p_file, uint32_t p_line, const char *p_message)
148148
abort();
149149
}
150150

151+
#if defined(_MACOSX) || defined(TARGET_SUBPLATFORM_IPHONE)
152+
extern "C"
153+
{
154+
#include <CoreFoundation/CoreFoundation.h>
155+
void NSLog(CFStringRef format, ...);
156+
void NSLogv(CFStringRef format, va_list args);
157+
}
158+
#endif
159+
151160
static void MCLogV(const char *p_file, uint32_t p_line,
152161
const char *p_format, va_list p_args)
153162
{
154163
MCAutoStringRef t_string;
155164
/* UNCHECKED */ MCStringFormatV(&t_string, p_format, p_args);
156165

166+
#if defined(_MACOSX) || defined(TARGET_SUBPLATFORM_IPHONE)
167+
CFStringRef t_cf_string;
168+
if (MCStringConvertToCFStringRef(*t_string, t_cf_string))
169+
{
170+
NSLog(CFSTR("%@"), t_cf_string);
171+
CFRelease(t_cf_string);
172+
}
173+
#else
157174
MCAutoStringRefAsSysString t_string_sys;
158175
/* UNCHECKED */ t_string_sys.Lock(*t_string);
159176
fprintf(stderr, "[%d] %s\n", getpid(), *t_string_sys);
177+
#endif
160178
}
161179

162180
void __MCLog(const char *p_file, uint32_t p_line, const char *p_format, ...)

libfoundation/src/system-library-posix.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class __MCSLibraryHandlePosix
7272
RTLD_LAZY);
7373
if (m_handle == nullptr)
7474
{
75+
MCLog("dlopen failed %s",dlerror());
7576
/* TODO: dlerror message */
7677
return __MCSLibraryThrowCreateWithNativePathFailed(p_native_path);
7778
}

0 commit comments

Comments
 (0)