This commit is contained in:
2025-11-26 13:38:53 +05:30
parent 38eb431eff
commit 128bf23e1e

View File

@ -1,16 +1,16 @@
// IACore-OSS; The Core Library for All IA Open Source Projects // IACore-OSS; The Core Library for All IA Open Source Projects
// Copyright (C) 2025 IAS (ias@iasoft.dev) // Copyright (C) 2025 IAS (ias@iasoft.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
@ -50,12 +50,16 @@ namespace IACore
s_logLevel = logLevel; s_logLevel = logLevel;
} }
VOID Logger::LogInternal(IN PCCHAR prefix, IN PCCHAR tag, IN String&& msg) VOID Logger::LogInternal(IN PCCHAR prefix, IN PCCHAR tag, IN String &&msg)
{ {
std::chrono::duration<double> elapsed = HRClock::now() - s_startTime; std::chrono::duration<double> elapsed = HRClock::now() - s_startTime;
double timestamp = elapsed.count(); double timestamp = elapsed.count();
const auto outLine = std::format("{} [{:>8.3f}]: [{}]: {}\033[39m\n", prefix, timestamp, tag, msg); const auto outLine = std::format("[{:>8.3f}]: [{}]: {}", timestamp, tag, msg);
const auto outStream = s_logFile ? s_logFile->GetStreamHandle() : &std::cout; std::cout << prefix << outLine << "\033[39m\n";
outStream->write(outLine.data(), outLine.size()); if (s_logFile)
{
s_logFile->GetStreamHandle()->write(outLine.data(), outLine.size());
s_logFile->GetStreamHandle()->put('\n');
}
} }
} } // namespace IACore