mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-02 14:50:05 +01:00
[Logs] Print colors only on TTY
This commit is contained in:
parent
095b6b7728
commit
389627ff73
|
|
@ -4,6 +4,7 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
static void append_hex(std::string &out, std::uintmax_t value) {
|
||||
|
|
@ -226,6 +227,11 @@ void _orbis_log_print(LogLevel lvl, const char *msg, std::string_view names,
|
|||
break;
|
||||
}
|
||||
|
||||
std::fprintf(stderr, "%s%s\e[0m\n", color, text.c_str());
|
||||
static const bool istty = isatty(fileno(stderr));
|
||||
if (istty) {
|
||||
std::fprintf(stderr, "%s%s\e[0m\n", color, text.c_str());
|
||||
} else {
|
||||
std::fprintf(stderr, "%s\n", text.c_str());
|
||||
}
|
||||
}
|
||||
} // namespace orbis::logs
|
||||
|
|
|
|||
Loading…
Reference in a new issue