From 05f356f6e0ef608fa138bc0a4e0ea7063f6035b1 Mon Sep 17 00:00:00 2001 From: ravinsp <33562092+ravinsp@users.noreply.github.com> Date: Sat, 26 Sep 2020 21:33:15 +0530 Subject: [PATCH] Fixed log line severity indicator issue. --- src/hplog.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/hplog.cpp b/src/hplog.cpp index a818f508..b7e4428c 100644 --- a/src/hplog.cpp +++ b/src/hplog.cpp @@ -19,6 +19,27 @@ namespace hplog return plog::util::nstring(); } + static inline const char *severity_to_string(plog::Severity severity) + { + switch (severity) + { + case plog::Severity::fatal: + return "fat"; + case plog::Severity::error: + return "err"; + case plog::Severity::warning: + return "wrn"; + case plog::Severity::info: + return "inf"; + case plog::Severity::debug: + return "dbg"; + case plog::Severity::verbose: + return "ver"; + default: + return "def"; + } + } + static plog::util::nstring format(const plog::Record &record) { tm t; @@ -27,7 +48,7 @@ namespace hplog plog::util::nostringstream ss; ss << t.tm_year + 1900 << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_mon + 1 << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_mday << PLOG_NSTR(" "); ss << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_hour << PLOG_NSTR(":") << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_min << PLOG_NSTR(":") << std::setfill(PLOG_NSTR('0')) << std::setw(2) << t.tm_sec << PLOG_NSTR(" "); - ss << PLOG_NSTR("[") << conf::cfg.loglevel << PLOG_NSTR("][hp] "); + ss << PLOG_NSTR("[") << severity_to_string(record.getSeverity()) << PLOG_NSTR("][hpc] "); ss << record.getMessage() << PLOG_NSTR("\n"); return ss.str();