@@ -287,33 +287,51 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
287287 OutputDebugStringA (buffer );
288288#endif
289289#else /* !HAVE_QT && !__WINRT__ */
290- #if TARGET_OS_IPHONE
291- #if TARGET_IPHONE_SIMULATOR
292- vprintf (fmt , ap );
293- #elif __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_10_0 || __TV_OS_VERSION_MIN_REQUIRED > __TVOS_10_0
294- int _len = vsnprintf (NULL , 0 , fmt , ap ) + 1 ;
295- char buffer [_len ]; /* TODO/FIXME - VLA - C89 backwards compatibility */
296- vsnprintf (buffer , _len , fmt , ap );
290+ #if TARGET_OS_MAC /* any apple variant: macOS, iOS, tvOS, ... */
291+ char buffer [2048 ];
292+ va_list ap_cp ;
293+ va_copy (ap_cp , ap );
294+ vsnprintf (buffer , sizeof (buffer ), fmt , ap_cp );
295+ va_end (ap_cp );
296+
297+ #if TARGET_OS_OSX /* really macOS */
298+ /* macOS: output to stdout for developer convenience */
299+ printf ("%s %s" , tag_v , buffer );
300+ #elif TARGET_OS_IPHONE /* iOS, tvOS, ... */
301+ #if TARGET_OS_SIMULATOR
302+ /* iOS Simulator: output to stderr for Xcode console */
303+ fprintf (stderr , "%s %s" , tag_v , buffer );
304+ #elif defined(__IPHONE_10_0 ) && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0 )
305+ /* iOS 10+ and tvOS 10+: use os_log for unified logging */
306+ os_log (OS_LOG_DEFAULT , "%s %s" , tag_v , buffer );
307+ #elif defined(__TV_OS_VERSION_MIN_REQUIRED ) && defined(__TVOS_10_0 ) && (__TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0 )
308+ /* tvOS 10+: use os_log for unified logging */
297309 os_log (OS_LOG_DEFAULT , "%s %s" , tag_v , buffer );
298310#else
311+ /* iOS 9 and earlier: use ASL (Apple System Logger) */
299312 static aslclient asl_client ;
300313 static int asl_initialized = 0 ;
301314 if (!asl_initialized )
302315 {
303- asl_client = asl_open (
304- FILE_PATH_PROGRAM_NAME ,
316+ asl_client = asl_open (FILE_PATH_PROGRAM_NAME ,
305317 "com.apple.console" ,
306318 ASL_OPT_STDERR | ASL_OPT_NO_DELAY );
307319 asl_initialized = 1 ;
308320 }
309321 aslmsg msg = asl_new (ASL_TYPE_MSG );
310322 asl_set (msg , ASL_KEY_READ_UID , "-1" );
311- if (tag )
312- asl_log (asl_client , msg , ASL_LEVEL_NOTICE , "%s" , tag );
313- asl_vlog (asl_client , msg , ASL_LEVEL_NOTICE , fmt , ap );
323+ asl_log (asl_client , msg , ASL_LEVEL_NOTICE , "%s %s" , tag_v , buffer );
314324 asl_free (msg );
315325#endif
316- #endif
326+ #endif /* TARGET_OS_IPHONE */
327+
328+ /* Always write to file for all Apple platforms */
329+ if (fp )
330+ {
331+ fprintf (fp , "%s %s" , tag_v , buffer );
332+ fflush (fp );
333+ }
334+ #else
317335#if defined(HAVE_LIBNX )
318336 mutexLock (& g_verbosity -> mtx );
319337#endif
@@ -327,6 +345,7 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
327345 mutexUnlock (& g_verbosity -> mtx );
328346#endif
329347
348+ #endif
330349#endif
331350#endif
332351}
@@ -531,7 +550,7 @@ void rarch_log_file_init(
531550 sizeof (log_file_path ));
532551 }
533552 else
534- log_file_path [0 ] = '\0' ;
553+ log_file_path [0 ] = '\0' ;
535554
536555 /* > Attempt to initialise log file */
537556 if (!string_is_empty (log_file_path ))
0 commit comments