From 24a2bb4a39c3d2e7f6e14074181fdaaf9222035c Mon Sep 17 00:00:00 2001 From: p-sam Date: Fri, 20 Sep 2019 13:52:41 +0000 Subject: [PATCH] Compact logs; add ms to timestamps --- sysmodule/src/clock_manager.cpp | 12 ++++++------ sysmodule/src/config.cpp | 2 +- sysmodule/src/file_utils.cpp | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sysmodule/src/clock_manager.cpp b/sysmodule/src/clock_manager.cpp index 15b9e151..a2c4a685 100644 --- a/sysmodule/src/clock_manager.cpp +++ b/sysmodule/src/clock_manager.cpp @@ -88,7 +88,7 @@ void ClockManager::Tick() if (hz != this->context->freqs[module] && this->context->enabled) { - FileUtils::LogLine("[mgr] Setting %s clock to %u.%u Mhz", Clocks::GetModuleName((SysClkModule)module, true), hz/1000000, hz/100000 - hz/1000000*10); + FileUtils::LogLine("[mgr] %s clock set : %u.%u Mhz", Clocks::GetModuleName((SysClkModule)module, true), hz/1000000, hz/100000 - hz/1000000*10); Clocks::SetHz((SysClkModule)module, hz); this->context->freqs[module] = hz; } @@ -110,14 +110,14 @@ bool ClockManager::RefreshContext() if(enabled != this->context->enabled) { this->context->enabled = enabled; - FileUtils::LogLine("[mgr] " TARGET " was %s", enabled ? "enabled" : "disabled"); + FileUtils::LogLine("[mgr] " TARGET " status: %s", enabled ? "enabled" : "disabled"); hasChanged = true; } std::uint64_t applicationTid = ProcessManagement::GetCurrentApplicationTid(); if (applicationTid != this->context->applicationTid) { - FileUtils::LogLine("[mgr] Application TitleID changed to: %016lX", applicationTid); + FileUtils::LogLine("[mgr] TitleID change: %016lX", applicationTid); this->context->applicationTid = applicationTid; hasChanged = true; } @@ -125,7 +125,7 @@ bool ClockManager::RefreshContext() SysClkProfile profile = Clocks::GetCurrentProfile(); if (profile != this->context->profile) { - FileUtils::LogLine("[mgr] Console profile changed to: %s", Clocks::GetProfileName(profile, true)); + FileUtils::LogLine("[mgr] Profile change: %s", Clocks::GetProfileName(profile, true)); this->context->profile = profile; hasChanged = true; } @@ -142,7 +142,7 @@ bool ClockManager::RefreshContext() hz = Clocks::GetCurrentHz((SysClkModule)module); if (hz != 0 && hz != this->context->freqs[module]) { - FileUtils::LogLine("[mgr] %s clock changed to %u.%u Mhz", Clocks::GetModuleName((SysClkModule)module, true), hz/1000000, hz/100000 - hz/1000000*10); + FileUtils::LogLine("[mgr] %s clock change: %u.%u Mhz", Clocks::GetModuleName((SysClkModule)module, true), hz/1000000, hz/100000 - hz/1000000*10); this->context->freqs[module] = hz; hasChanged = true; } @@ -152,7 +152,7 @@ bool ClockManager::RefreshContext() { if(hz) { - FileUtils::LogLine("[mgr] %s override changed to %u.%u Mhz", Clocks::GetModuleName((SysClkModule)module, true), hz/1000000, hz/100000 - hz/1000000*10); + FileUtils::LogLine("[mgr] %s override change: %u.%u Mhz", Clocks::GetModuleName((SysClkModule)module, true), hz/1000000, hz/100000 - hz/1000000*10); } else { diff --git a/sysmodule/src/config.cpp b/sysmodule/src/config.cpp index 53a2c4a6..1319c73c 100644 --- a/sysmodule/src/config.cpp +++ b/sysmodule/src/config.cpp @@ -50,7 +50,7 @@ Config *Config::CreateDefault() void Config::Load() { - FileUtils::LogLine("[cfg] reading %s", this->path.c_str()); + FileUtils::LogLine("[cfg] Reading %s", this->path.c_str()); this->Close(); this->mtime = this->CheckModificationTime(); diff --git a/sysmodule/src/file_utils.cpp b/sysmodule/src/file_utils.cpp index 5c87bb6f..262c8e35 100644 --- a/sysmodule/src/file_utils.cpp +++ b/sysmodule/src/file_utils.cpp @@ -44,11 +44,11 @@ void FileUtils::LogLine(const char *format, ...) if (file) { - time_t timer = time(NULL); - struct tm* timerTm = localtime(&timer); + struct timespec now; + clock_gettime(CLOCK_REALTIME, &now); + struct tm* nowTm = localtime(&now.tv_sec); - va_start(args, format); - fprintf(file, "[%04d-%02d-%02d %02d:%02d:%02d] ", timerTm->tm_year+1900, timerTm->tm_mon+1, timerTm->tm_mday, timerTm->tm_hour, timerTm->tm_min, timerTm->tm_sec); + fprintf(file, "[%04d-%02d-%02d %02d:%02d:%02d.%03ld] ", nowTm->tm_year+1900, nowTm->tm_mon+1, nowTm->tm_mday, nowTm->tm_hour, nowTm->tm_min, nowTm->tm_sec, now.tv_nsec / 1000000UL); vfprintf(file, format, args); fprintf(file, "\n"); fclose(file); @@ -111,8 +111,8 @@ Result FileUtils::Initialize() if (R_SUCCEEDED(rc)) { FileUtils::RefreshFlags(true); - FileUtils::LogLine("=== " TARGET " " TARGET_VERSION " ==="); g_has_initialized = true; + FileUtils::LogLine("=== " TARGET " " TARGET_VERSION " ==="); } return rc;