From 07f39ae47b1061034fe94b46a28f04c1d23c32c2 Mon Sep 17 00:00:00 2001 From: Dvir Volk Date: Wed, 31 Mar 2021 22:44:57 -0700 Subject: [PATCH] Added macros for RM_log logging levels (#4246) Added macros for RM_log logging levels, to avoid typos and the need to memorize the level strings by heart --- src/module.c | 8 ++++---- src/redismodule.h | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/module.c b/src/module.c index cf2305b56..f24c0af2a 100644 --- a/src/module.c +++ b/src/module.c @@ -5073,10 +5073,10 @@ void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va * printf-alike specifiers, while level is a string describing the log * level to use when emitting the log, and must be one of the following: * - * * "debug" - * * "verbose" - * * "notice" - * * "warning" + * * "debug" (`REDISMODULE_LOGLEVEL_DEBUG`) + * * "verbose" (`REDISMODULE_LOGLEVEL_VERBOSE`) + * * "notice" (`REDISMODULE_LOGLEVEL_NOTICE`) + * * "warning" (`REDISMODULE_LOGLEVEL_WARNING`) * * If the specified log level is invalid, verbose is used by default. * There is a fixed limit to the length of the log line this function is able diff --git a/src/redismodule.h b/src/redismodule.h index e7001ee7a..fba810de4 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -193,6 +193,12 @@ This flag should not be used directly by the module. #define REDISMODULE_NOT_USED(V) ((void) V) +/* Logging level strings */ +#define REDISMODULE_LOGLEVEL_DEBUG "debug" +#define REDISMODULE_LOGLEVEL_VERBOSE "verbose" +#define REDISMODULE_LOGLEVEL_NOTICE "notice" +#define REDISMODULE_LOGLEVEL_WARNING "warning" + /* Bit flags for aux_save_triggers and the aux_load and aux_save callbacks */ #define REDISMODULE_AUX_BEFORE_RDB (1<<0) #define REDISMODULE_AUX_AFTER_RDB (1<<1)