aboutsummaryrefslogtreecommitdiffstats
path: root/CommonLibs/debug.h
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-07-01 20:13:32 +0200
committerpespin <pespin@sysmocom.de>2019-07-19 11:44:13 +0000
commitc9202ab0be5e3e89f5fa4236ef45d550cee91af6 (patch)
tree85e790a6fdf5db260eceabdb463a714cc30a1b8a /CommonLibs/debug.h
parentb49a42e70b65d71ce705be931ddcfe88109da8d8 (diff)
Logger: global Log mutex is now available from C code
This way the C++ logging API can still be used while allowing for C files to use the same mutex. Change-Id: I473e57479f8ae98a84ad00b76ff338f79f732236
Diffstat (limited to 'CommonLibs/debug.h')
-rw-r--r--CommonLibs/debug.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/CommonLibs/debug.h b/CommonLibs/debug.h
index a5b9271..760ab32 100644
--- a/CommonLibs/debug.h
+++ b/CommonLibs/debug.h
@@ -1,5 +1,10 @@
#pragma once
+#include <stdbool.h>
+#include <pthread.h>
+
+#include <osmocom/core/logging.h>
+
extern const struct log_info log_info;
/* Debug Areas of the code */
@@ -9,3 +14,22 @@ enum {
DDEV,
DLMS,
};
+
+
+bool log_mutex_init();
+void log_mutex_lock();
+void log_mutex_unlock();
+void log_mutex_lock_canceldisable(int *st);
+void log_mutex_unlock_canceldisable(int st);
+
+#define CLOGC(category, level, fmt, args...) do { \
+ log_mutex_lock(); \
+ LOGP(category, level, "[tid=%lu] " fmt, pthread_self(), ##args); \
+ log_mutex_unlock(); \
+} while(0)
+
+#define CLOGCHAN(chan, category, level, fmt, args...) do { \
+ log_mutex_lock(); \
+ LOGP(category, level, "[tid=%lu][chan=%lu] " fmt, pthread_self(), chan, ##args); \
+ log_mutex_unlock(); \
+} while(0)