Minor refactoring
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user