1
0
mirror of synced 2025-02-17 18:59:21 +01:00

sys: Fixed logging to file omitting all tags and new lines

This commit is contained in:
WerWolv 2022-02-16 21:31:47 +01:00
parent 7117592f38
commit 90753f4d42
2 changed files with 16 additions and 8 deletions

View File

@ -13,18 +13,26 @@ namespace hex::log {
namespace {
void printPrefix(const fmt::text_style &ts, const std::string &level) {
void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level) {
const auto now = fmt::localtime(std::chrono::system_clock::now());
fmt::print("[{0:%H:%M:%S}] ", now);
fmt::print(ts, "{0} ", level);
fmt::print("[{0}] ", IMHEX_PROJECT_NAME);
fmt::print(dest, "[{0:%H:%M:%S}] ", now);
if (isRedirected())
fmt::print(dest, "{0} ", level);
else
fmt::print(dest, ts, "{0} ", level);
fmt::print(dest, "[{0}] ", IMHEX_PROJECT_NAME);
}
template<typename... T>
void print(const fmt::text_style &ts, const std::string &level, const std::string &fmt, auto... args) {
printPrefix(ts, level);
fmt::print(getDestination(), fmt::runtime(fmt), args...);
fmt::print("\n");
auto dest = getDestination();
printPrefix(dest, ts, level);
fmt::print(dest, fmt::runtime(fmt), args...);
fmt::print(dest, "\n");
}
}

View File

@ -314,7 +314,7 @@ namespace hex {
namespace ContentRegistry::DataProcessorNode {
void impl::add(const impl::Entry &entry) {
log::info("Registered new data processor node type: [{}]: ", entry.category, entry.name);
log::info("Registered new data processor node type: [{}]: {}", entry.category, entry.name);
getEntries().push_back(entry);
}