mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
log: fix prefix
This commit is contained in:
parent
899dd7510c
commit
07d3783035
2 changed files with 5 additions and 6 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Reference in a new issue