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:
29
src/mm-log.h
29
src/mm-log.h
@@ -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>
|
||||
*/
|
||||
|
||||
#ifndef MM_LOG_H
|
||||
@@ -26,26 +27,22 @@ typedef enum {
|
||||
MM_LOG_LEVEL_DEBUG = 0x00000008
|
||||
} MMLogLevel;
|
||||
|
||||
#define mm_err(...) \
|
||||
_mm_log (G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_ERR, ## __VA_ARGS__ )
|
||||
#define mm_obj_err(obj, ...) _mm_log (obj, G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_ERR, ## __VA_ARGS__ )
|
||||
#define mm_obj_warn(obj, ...) _mm_log (obj, G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_WARN, ## __VA_ARGS__ )
|
||||
#define mm_obj_info(obj, ...) _mm_log (obj, G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_INFO, ## __VA_ARGS__ )
|
||||
#define mm_obj_dbg(obj, ...) _mm_log (obj, G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_DEBUG, ## __VA_ARGS__ )
|
||||
|
||||
#define mm_warn(...) \
|
||||
_mm_log (G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_WARN, ## __VA_ARGS__ )
|
||||
#define mm_err(...) mm_obj_err (NULL, ## __VA_ARGS__ )
|
||||
#define mm_warn(...) mm_obj_warn (NULL, ## __VA_ARGS__ )
|
||||
#define mm_info(...) mm_obj_info (NULL, ## __VA_ARGS__ )
|
||||
#define mm_dbg(...) mm_obj_dbg (NULL, ## __VA_ARGS__ )
|
||||
|
||||
#define mm_info(...) \
|
||||
_mm_log (G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_INFO, ## __VA_ARGS__ )
|
||||
|
||||
#define mm_dbg(...) \
|
||||
_mm_log (G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_DEBUG, ## __VA_ARGS__ )
|
||||
|
||||
#define mm_log(level, ...) \
|
||||
_mm_log (G_STRLOC, G_STRFUNC, level, ## __VA_ARGS__ )
|
||||
|
||||
void _mm_log (const char *loc,
|
||||
void _mm_log (gpointer obj,
|
||||
const char *loc,
|
||||
const char *func,
|
||||
MMLogLevel level,
|
||||
const char *fmt,
|
||||
...) __attribute__((__format__ (__printf__, 4, 5)));
|
||||
...) __attribute__((__format__ (__printf__, 5, 6)));
|
||||
|
||||
gboolean mm_log_set_level (const char *level, GError **error);
|
||||
|
||||
|
Reference in New Issue
Block a user