Created
April 19, 2018 17:25
-
-
Save dvirsky/8998e79855e03386577a8afc30b9d729 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <redismodule.h> | |
#include <stdarg.h> | |
extern RedisModuleCtx *logCtx_g; | |
// FFS let's have contstants for the logging levels and not hard code them | |
#define RS_LOG_WARNING "warning" | |
#define ... | |
void RS_SafeLogInit(RedisModuleCtx *ctx) { | |
// block the ctx | |
// create a thread safe ctx from the BC | |
// unblock | |
} | |
#define RS_SafeLog(ctx, level, msg, ...) { \ | |
if (ctx) { | |
RedisModule_Log(ctx, level, msg, __VA_ARGS__); | |
if(!logCtx_g) RS_SafeLogInit(ctx); | |
} else if (logCtx_g) { | |
RedisModule_Log(logCtx_g, level, msg, __VA_ARGS__); | |
} else { | |
fprintf(stderr, level # msg, __VA_ARGS__); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment