NSLog with UTF-8, better color handling
This commit is contained in:
parent
76bf574668
commit
9b751fced8
|
@ -14,7 +14,7 @@
|
|||
|
||||
ConsoleListener::ConsoleListener()
|
||||
{
|
||||
#ifdef LOG_TO_PTY
|
||||
#if defined(LOG_TO_PTY) || defined(__APPLE__)
|
||||
m_use_color = 1;
|
||||
#elif defined(__SWITCH__)
|
||||
m_use_color = 0;
|
||||
|
|
|
@ -30,8 +30,16 @@ int darw_printf(const char* text, ...)
|
|||
va_start(args, text);
|
||||
vsnprintf(temp, sizeof(temp), text, args);
|
||||
va_end(args);
|
||||
|
||||
NSLog(@"%s", temp);
|
||||
|
||||
NSString* log = [NSString stringWithCString:temp encoding: NSUTF8StringEncoding];
|
||||
if (getenv("TERM") == NULL) //Xcode console does not support colors
|
||||
{
|
||||
log = [log stringByReplacingOccurrencesOfString:@"\x1b[0m" withString:@""];
|
||||
log = [log stringByReplacingOccurrencesOfString:@"\x1b[92m" withString:@"ℹ️ "];
|
||||
log = [log stringByReplacingOccurrencesOfString:@"\x1b[91m" withString:@"⚠️ "];
|
||||
log = [log stringByReplacingOccurrencesOfString:@"\x1b[93m" withString:@"🛑 "];
|
||||
}
|
||||
NSLog(@"%@", log);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue