diff --git a/release/files_common b/release/files_common index 2f38d2387551ce..04dddbfe711c89 100644 --- a/release/files_common +++ b/release/files_common @@ -200,6 +200,8 @@ selfdrive/common/version.h selfdrive/common/swaglog.h selfdrive/common/swaglog.cc +selfdrive/common/statlog.h +selfdrive/common/statlog.cc selfdrive/common/util.cc selfdrive/common/util.h selfdrive/common/queue.h diff --git a/selfdrive/common/swaglog.cc b/selfdrive/common/swaglog.cc index d74a57fc330ab6..17d9675e8e1d2b 100644 --- a/selfdrive/common/swaglog.cc +++ b/selfdrive/common/swaglog.cc @@ -18,7 +18,8 @@ class SwaglogState : public LogState { public: - inline SwaglogState() : LogState("ipc:///tmp/logmessage") { + SwaglogState() : LogState("ipc:///tmp/logmessage") { + ctx_j = json11::Json::object {}; print_level = CLOUDLOG_WARNING; const char* print_lvl = getenv("LOGPRINT"); if (print_lvl) { diff --git a/selfdrive/common/util.h b/selfdrive/common/util.h index d844f034b79fbd..bf0df3bcaa6889 100644 --- a/selfdrive/common/util.h +++ b/selfdrive/common/util.h @@ -168,7 +168,12 @@ void update_max_atomic(std::atomic& max, T const& value) { class LogState { public: - inline LogState(const char* socket) { + std::mutex lock; + void *zctx; + void *sock; + int print_level; + + LogState(const char* endpoint) { zctx = zmq_ctx_new(); sock = zmq_socket(zctx, ZMQ_PUSH); @@ -176,14 +181,10 @@ class LogState { int timeout = 100; zmq_setsockopt(sock, ZMQ_LINGER, &timeout, sizeof(timeout)); - zmq_connect(sock, socket); + zmq_connect(sock, endpoint); }; - inline ~LogState() { + ~LogState() { zmq_close(sock); zmq_ctx_destroy(zctx); } - std::mutex lock; - void *zctx; - void *sock; - int print_level; };