Minor refactoring

This commit is contained in:
Pablo Rodriguez
2025-07-29 17:17:28 -04:00
parent 472d35497d
commit aebd69a027
10 changed files with 69 additions and 57 deletions

View File

@@ -3,16 +3,20 @@
#include <format>
#include <chrono>
namespace ugly {
ugly::TimestampLog::TimestampLog(std::ostream &os, std::string_view description):
TimestampLog::TimestampLog(std::string_view description, std::ostream &os):
mStartTime{std::chrono::high_resolution_clock::now()},
mrOutputStream{os},
mDescription{description},
mStart{std::chrono::high_resolution_clock::now()} {}
mDescription{description} {}
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();
void TimestampLog::vlog(std::string_view fmt, std::format_args args) {
using namespace std::chrono;
auto now = high_resolution_clock::now();
auto timestamp = duration_cast<duration<float>>(now - mStartTime).count();
auto message = std::vformat(fmt, args);
mrOutputStream << std::format("[{:9.4f}] {}: {}\n", timestamp, mDescription, message);
}
}

View File

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