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)
//
//
// 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
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
@ -50,12 +50,16 @@ namespace IACore
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;
double timestamp = elapsed.count();
const auto outLine = std::format("{} [{:>8.3f}]: [{}]: {}\033[39m\n", prefix, timestamp, tag, msg);
const auto outStream = s_logFile ? s_logFile->GetStreamHandle() : &std::cout;
outStream->write(outLine.data(), outLine.size());
const auto outLine = std::format("[{:>8.3f}]: [{}]: {}", timestamp, tag, msg);
std::cout << prefix << outLine << "\033[39m\n";
if (s_logFile)
{
s_logFile->GetStreamHandle()->write(outLine.data(), outLine.size());
s_logFile->GetStreamHandle()->put('\n');
}
}
}
} // namespace IACore