mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
sys: Added time and source to logger output
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/color.h>
|
||||
#include <fmt/chrono.h>
|
||||
|
||||
namespace hex::log {
|
||||
|
||||
namespace {
|
||||
|
||||
void printPrefix() {
|
||||
const auto now = fmt::localtime(std::chrono::system_clock::now());
|
||||
fmt::print("[{0:%H:%M:%S}] [{1}] ", now, IMHEX_PROJECT_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FILE *getDestination();
|
||||
bool isRedirected();
|
||||
|
||||
@@ -15,6 +27,7 @@ namespace hex::log {
|
||||
|
||||
template<typename S, typename... Args>
|
||||
void print(const fmt::text_style &ts, const S &fmt, const Args &...args) {
|
||||
printPrefix();
|
||||
if (isRedirected())
|
||||
fmt::print(getDestination(), fmt::runtime(fmt), args...);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user