diff options
author | Torsten Hilbrich <torsten.hilbrich@secunet.com> | 2017-06-21 12:54:35 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-06-21 13:02:39 +0200 |
commit | b4ad1e8a21c1b175eb2459939120c5fb1fef2c08 (patch) | |
tree | 8380493fa220b553dd8507775dfda9a81527c329 /src/mm-log.h | |
parent | 0e854644dbd896577eaa8f9b05c10aa6283b9533 (diff) |
log: Refactor evaluation of log level
Starting with adding a typed enum type for the log level named
MMLogLevel.
Suggested-By: Aleksander Morgado <aleksander@aleksander.es>
The level was checked twice in _mm_log. Once at the beginning and
again when turning the level into both the syslog priority and some
descriptive text which was added to the log level. Removing the check
at the second location as it was redundant.
Also adding a helper function to turn the MMLogLevel into the syslog
equivalent. This will become handy when adding support for systemd
journal.
Diffstat (limited to 'src/mm-log.h')
-rw-r--r-- | src/mm-log.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/mm-log.h b/src/mm-log.h index 292d68a0..6c34098e 100644 --- a/src/mm-log.h +++ b/src/mm-log.h @@ -19,31 +19,31 @@ #include <glib.h> /* Log levels */ -enum { - LOGL_ERR = 0x00000001, - LOGL_WARN = 0x00000002, - LOGL_INFO = 0x00000004, - LOGL_DEBUG = 0x00000008 -}; +typedef enum { + MM_LOG_LEVEL_ERR = 0x00000001, + MM_LOG_LEVEL_WARN = 0x00000002, + MM_LOG_LEVEL_INFO = 0x00000004, + MM_LOG_LEVEL_DEBUG = 0x00000008 +} MMLogLevel; #define mm_err(...) \ - _mm_log (G_STRLOC, G_STRFUNC, LOGL_ERR, ## __VA_ARGS__ ) + _mm_log (G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_ERR, ## __VA_ARGS__ ) #define mm_warn(...) \ - _mm_log (G_STRLOC, G_STRFUNC, LOGL_WARN, ## __VA_ARGS__ ) + _mm_log (G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_WARN, ## __VA_ARGS__ ) #define mm_info(...) \ - _mm_log (G_STRLOC, G_STRFUNC, LOGL_INFO, ## __VA_ARGS__ ) + _mm_log (G_STRLOC, G_STRFUNC, MM_LOG_LEVEL_INFO, ## __VA_ARGS__ ) #define mm_dbg(...) \ - _mm_log (G_STRLOC, G_STRFUNC, LOGL_DEBUG, ## __VA_ARGS__ ) + _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, const char *func, - guint32 level, + MMLogLevel level, const char *fmt, ...) __attribute__((__format__ (__printf__, 4, 5))); |