From d5835fc8a02dcb7eac39e08e0724ae96cd7ce8b5 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 18 Oct 2019 12:31:34 +0200 Subject: [PATCH] add info_long() method to log filter --- lib/include/srslte/common/log.h | 1 + lib/include/srslte/common/log_filter.h | 1 + lib/src/common/log_filter.cc | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/lib/include/srslte/common/log.h b/lib/include/srslte/common/log.h index 0bb876446..0230a350a 100644 --- a/lib/include/srslte/common/log.h +++ b/lib/include/srslte/common/log.h @@ -133,6 +133,7 @@ public: virtual void error(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; virtual void warning(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; virtual void info(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; + virtual void info_long(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0; virtual void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; virtual void debug_long(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0; diff --git a/lib/include/srslte/common/log_filter.h b/lib/include/srslte/common/log_filter.h index ff86cae0f..8cde2b96d 100644 --- a/lib/include/srslte/common/log_filter.h +++ b/lib/include/srslte/common/log_filter.h @@ -57,6 +57,7 @@ public: void error(const char * message, ...) __attribute__ ((format (printf, 2, 3))); void warning(const char * message, ...) __attribute__ ((format (printf, 2, 3))); void info(const char * message, ...) __attribute__ ((format (printf, 2, 3))); + void info_long(const char* message, ...) __attribute__((format(printf, 2, 3))); void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))); void debug_long(const char* message, ...) __attribute__((format(printf, 2, 3))); diff --git a/lib/src/common/log_filter.cc b/lib/src/common/log_filter.cc index 058a1b4fe..040e5e48a 100644 --- a/lib/src/common/log_filter.cc +++ b/lib/src/common/log_filter.cc @@ -153,6 +153,19 @@ void log_filter::info(const char * message, ...) { all_log_expand(LOG_LEVEL_INFO); } +void log_filter::info_long(const char* message, ...) +{ + if (level >= LOG_LEVEL_INFO) { + char* args_msg = NULL; + va_list args; + va_start(args, message); + if (vasprintf(&args_msg, message, args) > 0) + all_log(LOG_LEVEL_INFO, tti, args_msg, nullptr, strlen(args_msg), true); + va_end(args); + free(args_msg); + } +} + void log_filter::debug(const char * message, ...) { all_log_expand(LOG_LEVEL_DEBUG); }