1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

log: fix intialization of log level and pattern

This commit is contained in:
Steffen Vogel 2018-11-04 17:12:12 +01:00
parent f4e46f58f5
commit d33be2ffc7
2 changed files with 8 additions and 8 deletions

View file

@ -54,6 +54,8 @@ protected:
Logger logger = logging.get("log");
DistSink sinks;
Level level;
std::string pattern; /**< Logging format. */
std::string prefix; /**< Prefix each line with this string. */

View file

@ -35,16 +35,14 @@ using namespace villas;
/** The global log instance */
Log villas::logging;
Log::Log(Level level) :
sinks(std::make_shared<DistSink::element_type>()),
pattern("%H:%M:%S %P %^%l%$: %v")
Log::Log(Level level)
{
char *p = getenv("VILLAS_LOG_PREFIX");
if (p)
prefix = p;
spdlog::set_level(level);
spdlog::set_pattern(pattern, spdlog::pattern_time_type::utc);
setLevel(level);
setPattern("%H:%M:%S %^%l%$ %n: %v");
auto sink = std::make_shared<spdlog::sinks::stderr_color_sink_mt>();
@ -143,6 +141,8 @@ void Log::setPattern(const std::string &pat)
void Log::setLevel(Level lvl)
{
level = lvl;
spdlog::set_level(lvl);
}
@ -154,9 +154,7 @@ void Log::setLevel(const std::string &lvl)
if (it == l.end())
throw RuntimeError("Invalid log level {}", lvl);
level = spdlog::level::from_str(lvl);
setLevel(level);
setLevel(spdlog::level::from_str(lvl));
}
Log::Level Log::getLevel() const