Skip to content

Instantly share code, notes, and snippets.

@dvirsky
Created April 19, 2018 17:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvirsky/8998e79855e03386577a8afc30b9d729 to your computer and use it in GitHub Desktop.
Save dvirsky/8998e79855e03386577a8afc30b9d729 to your computer and use it in GitHub Desktop.
#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