MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaLogCommand

Function luaLogCommand

app/redis-6.2.6/src/scripting.c:986–1020  ·  view source on GitHub ↗

redis.log() */

Source from the content-addressed store, hash-verified

984
985/* redis.log() */
986int luaLogCommand(lua_State *lua) {
987 int j, argc = lua_gettop(lua);
988 int level;
989 sds log;
990
991 if (argc < 2) {
992 lua_pushstring(lua, "redis.log() requires two arguments or more.");
993 return lua_error(lua);
994 } else if (!lua_isnumber(lua,-argc)) {
995 lua_pushstring(lua, "First argument must be a number (log level).");
996 return lua_error(lua);
997 }
998 level = lua_tonumber(lua,-argc);
999 if (level < LL_DEBUG || level > LL_WARNING) {
1000 lua_pushstring(lua, "Invalid debug level.");
1001 return lua_error(lua);
1002 }
1003 if (level < server.verbosity) return 0;
1004
1005 /* Glue together all the arguments */
1006 log = sdsempty();
1007 for (j = 1; j < argc; j++) {
1008 size_t len;
1009 char *s;
1010
1011 s = (char*)lua_tolstring(lua,(-argc)+j,&len);
1012 if (s) {
1013 if (j != 1) log = sdscatlen(log," ",1);
1014 log = sdscatlen(log,s,len);
1015 }
1016 }
1017 serverLogRaw(level,log);
1018 sdsfree(log);
1019 return 0;
1020}
1021
1022/* redis.setresp() */
1023int luaSetResp(lua_State *lua) {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected