diff --git a/include/villas/log_config.h b/include/villas/log_config.h index d7322fd0a..c51dc0a61 100644 --- a/include/villas/log_config.h +++ b/include/villas/log_config.h @@ -33,6 +33,9 @@ struct log; extern "C"{ #endif +/** Wrapper for log_parse, to check if config file exists **/ +int log_parse_wrapper(struct log *l, json_t *cfg); + /** Parse logging configuration. */ int log_parse(struct log *l, json_t *cfg); @@ -43,4 +46,4 @@ void jerror(json_error_t *err, const char *fmt, ...) #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/lib/log_config.c b/lib/log_config.c index 4d8e162c7..4151c061b 100644 --- a/lib/log_config.c +++ b/lib/log_config.c @@ -31,6 +31,24 @@ #include #include +int log_parse_wrapper(struct log *l, json_t *cfg) +{ + int ret; + json_t *json_logging = NULL; + json_error_t err; + + ret = json_unpack_ex(cfg, &err, 0, "{s?: o}", + "logging", &json_logging + ); + if (ret) + jerror(&err, "Failed to parse global configuration"); + + if(json_logging) + log_parse(l, json_logging); + + return 0; +} + int log_parse(struct log *l, json_t *cfg) { const char *facilities = NULL; diff --git a/src/villas-hook.cpp b/src/villas-hook.cpp index 039844542..5cbdf2f45 100644 --- a/src/villas-hook.cpp +++ b/src/villas-hook.cpp @@ -165,6 +165,10 @@ check: if (optarg == endptr) if (ret) error("Failed to initialize log"); + ret = log_parse_wrapper(&l, cfg_cli); + if (ret) + error("Failed to parse log"); + ret = log_open(&l); if (ret) error("Failed to start log"); diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index d01691ca5..2330d83e3 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -117,6 +117,10 @@ int main(int argc, char *argv[]) if (ret) error("Failed to initialize log"); + ret = log_parse_wrapper(&l, n.cfg); + if (ret) + error("Failed to parse log"); + ret = log_open(&l); if (ret) error("Failed to start log"); diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index 9cb99f4ef..c591c853e 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -127,6 +127,8 @@ check: if (optarg == endptr) super_node_init(&sn); super_node_parse_uri(&sn, configfile); + log_open(&sn.log); + signals_init(quit); rt_init(sn.priority, sn.affinity); memory_init(sn.hugepages);