summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/logging/nm-logging.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/logging/nm-logging.h b/src/logging/nm-logging.h
index a4392860cc..fdbed088d6 100644
--- a/src/logging/nm-logging.h
+++ b/src/logging/nm-logging.h
@@ -29,6 +29,8 @@
#include <glib.h>
#include <glib-object.h>
+#include "nm-utils-internal.h"
+
/* Log domains */
enum {
LOGD_NONE = 0LL,
@@ -106,6 +108,31 @@ GQuark nm_logging_error_quark (void);
} \
} G_STMT_END
+
+#define _nm_log_ptr(level, domain, self, ...) \
+ nm_log ((level), (domain), "[%p] " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), self _NM_UTILS_MACRO_REST(__VA_ARGS__))
+
+/* log a message for an object (with providing a generic @self pointer) */
+#define nm_log_ptr(level, domain, self, ...) \
+ G_STMT_START { \
+ if ((level) <= LOGL_DEBUG) { \
+ _nm_log_ptr ((level), (domain), (self), __VA_ARGS__); \
+ } else { \
+ nm_log ((level), (domain), __VA_ARGS__); \
+ } \
+ } G_STMT_END
+
+
+#define _nm_log_obj(level, domain, self, ...) \
+ _nm_log_ptr ((level), (domain), (self), __VA_ARGS__)
+
+/* log a message for an object (with providing a @self pointer to a GObject).
+ * Contrary to nm_log_ptr(), @self must be a GObject type (or %NULL).
+ * As of now, nm_log_obj() is identical to nm_log_ptr(), but we might change that */
+#define nm_log_obj(level, domain, self, ...) \
+ nm_log_ptr ((level), (domain), (self), __VA_ARGS__)
+
+
void _nm_log (const char *loc,
const char *func,
guint32 level,