log: new object logging support

So that we can provide the specific object id in every log associated
to a given object.
This commit is contained in:
Aleksander Morgado
2020-04-08 16:35:08 +02:00
parent faccb3b2b4
commit 9bcadea172
30 changed files with 203 additions and 47 deletions
+8 -2
View File
@@ -10,7 +10,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2011 Red Hat, Inc.
* Copyright (C) 2011-2020 Red Hat, Inc.
* Copyright (C) 2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#define _GNU_SOURCE
@@ -41,6 +42,7 @@
#endif
#include "mm-log.h"
#include "mm-log-object.h"
enum {
TS_FLAG_NONE = 0,
@@ -200,7 +202,8 @@ log_backend_systemd_journal (const char *loc,
#endif
void
_mm_log (const char *loc,
_mm_log (gpointer obj,
const char *loc,
const char *func,
MMLogLevel level,
const char *fmt,
@@ -243,6 +246,9 @@ _mm_log (const char *loc,
g_string_append_printf (msgbuf, "[%s] %s(): ", loc, func);
#endif
if (obj)
g_string_append_printf (msgbuf, "[%s] ", mm_log_object_get_id (MM_LOG_OBJECT (obj)));
va_start (args, fmt);
g_string_append_vprintf (msgbuf, fmt, args);
va_end (args);