1
0
mirror of synced 2024-11-24 07:40:17 +01:00

impr: Disable console color output in web version

This commit is contained in:
WerWolv 2024-02-01 12:09:43 +01:00
parent dfeb9dbc84
commit baaf84298c
3 changed files with 14 additions and 4 deletions

View File

@ -15,6 +15,7 @@
namespace hex::log::impl {
static wolv::io::File s_loggerFile;
static bool s_colorOutputEnabled = false;
std::mutex g_loggerMutex;
FILE *getDestination() {
@ -40,11 +41,16 @@ namespace hex::log::impl {
s_loggerFile = wolv::io::File(path / hex::format("{0:%Y%m%d_%H%M%S}.log", fmt::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()))), wolv::io::File::Mode::Create);
s_loggerFile.disableBuffering();
if (s_loggerFile.isValid()) break;
if (s_loggerFile.isValid()) {
s_colorOutputEnabled = true;
break;
}
}
}
void enableColorPrinting() {
s_colorOutputEnabled = true;
#if defined(OS_WINDOWS)
auto hConsole = ::GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole != INVALID_HANDLE_VALUE) {
@ -73,10 +79,10 @@ namespace hex::log::impl {
fmt::print(dest, "[{0:%H:%M:%S}] ", now);
if (isRedirected())
fmt::print(dest, "{0} ", level);
else
if (s_colorOutputEnabled)
fmt::print(dest, ts, "{0} ", level);
else
fmt::print(dest, "{0} ", level);
std::string projectThreadTag = projectName;
if (auto threadName = TaskManager::getCurrentThreadName(); !threadName.empty())

View File

@ -48,6 +48,8 @@ namespace hex {
}
void Window::initNative() {
log::impl::enableColorPrinting();
// Add plugin library folders to dll search path
for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
if (std::fs::exists(path))

View File

@ -21,6 +21,8 @@ namespace hex {
}
void Window::initNative() {
log::impl::enableColorPrinting();
// Add plugin library folders to dll search path
for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
if (std::fs::exists(path))