Implemented logging utilities

This commit is contained in:
Pablo Rodriguez
2025-07-28 08:29:53 -04:00
parent 9a38c557f0
commit 472d35497d
16 changed files with 138 additions and 26 deletions

View File

@@ -0,0 +1,18 @@
#include "TimestampLog.hpp"
#include <format>
#include <chrono>
ugly::TimestampLog::TimestampLog(std::ostream &os, std::string_view description):
mrOutputStream{os},
mDescription{description},
mStart{std::chrono::high_resolution_clock::now()} {}
void ugly::TimestampLog::vlog(std::string_view fmt, std::format_args args) {
auto now = std::chrono::high_resolution_clock::now();
auto timestamp = std::chrono::duration_cast<std::chrono::duration<float>>(now - mStart).count();
auto message = std::vformat(fmt, args);
mrOutputStream << std::format("[{:9.4f}] {}: {}\n", timestamp, mDescription, message);
}

View File

@@ -0,0 +1,3 @@
#include "LogUtils.hpp"
ugly::LogAlias ugly::log{nullptr};