Commit 9a986194 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

log: fix prefix

parent 59eaf21f
......@@ -87,7 +87,7 @@ public:
Logger get(const std::string &name);
void setFormatter(const std::string &pattern);
void setFormatter(const std::string &pattern, const std::string &pfx = "");
void setLevel(Level lvl);
void setLevel(const std::string &lvl);
......
......@@ -74,13 +74,11 @@ Log::Log(Level lvl) :
pattern("%H:%M:%S %^%-4t%$ %-16n %v")
{
char *p = getenv("VILLAS_LOG_PREFIX");
if (p)
prefix = p;
sinks = std::make_shared<DistSink::element_type>();
setLevel(level);
setFormatter(pattern);
setFormatter(pattern, p ? p : "");
/* Default sink */
sink = std::make_shared<spdlog::sinks::stderr_color_sink_mt>();
......@@ -174,13 +172,14 @@ void Log::parse(json_t *json)
}
}
void Log::setFormatter(const std::string &pat)
void Log::setFormatter(const std::string &pat, const std::string &pfx)
{
pattern = pat;
prefix = pfx;
formatter = std::make_shared<spdlog::pattern_formatter>(spdlog::pattern_time_type::utc);
formatter->add_flag<CustomLevelFlag>('t');
formatter->set_pattern(pattern);
formatter->set_pattern(prefix + pattern);
spdlog::set_formatter(formatter->clone());
sinks->set_formatter(formatter->clone());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment