MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaLogCommand

Function luaLogCommand

src/scripting.cpp:1000–1034  ·  view source on GitHub ↗

redis.log() */

Source from the content-addressed store, hash-verified

998
999/* redis.log() */
1000int luaLogCommand(lua_State *lua) {
1001 int j, argc = lua_gettop(lua);
1002 int level;
1003 sds log;
1004
1005 if (argc < 2) {
1006 lua_pushstring(lua, "redis.log() requires two arguments or more.");
1007 return lua_error(lua);
1008 } else if (!lua_isnumber(lua,-argc)) {
1009 lua_pushstring(lua, "First argument must be a number (log level).");
1010 return lua_error(lua);
1011 }
1012 level = lua_tonumber(lua,-argc);
1013 if (level < LL_DEBUG || level > LL_WARNING) {
1014 lua_pushstring(lua, "Invalid debug level.");
1015 return lua_error(lua);
1016 }
1017 if (level < cserver.verbosity) return 0;
1018
1019 /* Glue together all the arguments */
1020 log = sdsempty();
1021 for (j = 1; j < argc; j++) {
1022 size_t len;
1023 char *s;
1024
1025 s = (char*)lua_tolstring(lua,(-argc)+j,&len);
1026 if (s) {
1027 if (j != 1) log = sdscatlen(log," ",1);
1028 log = sdscatlen(log,s,len);
1029 }
1030 }
1031 serverLogRaw(level,log);
1032 sdsfree(log);
1033 return 0;
1034}
1035
1036/* redis.setresp() */
1037int luaSetResp(lua_State *lua) {

Callers

nothing calls this directly

Calls 10

lua_gettopFunction · 0.85
lua_pushstringFunction · 0.85
lua_errorFunction · 0.85
lua_isnumberFunction · 0.85
lua_tonumberFunction · 0.85
sdsemptyFunction · 0.85
lua_tolstringFunction · 0.85
sdscatlenFunction · 0.85
serverLogRawFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected