redis.log() */
| 984 | |
| 985 | /* redis.log() */ |
| 986 | int 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() */ |
| 1023 | int luaSetResp(lua_State *lua) { |
nothing calls this directly
no test coverage detected