redis.log() */
| 998 | |
| 999 | /* redis.log() */ |
| 1000 | int 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() */ |
| 1037 | int luaSetResp(lua_State *lua) { |
nothing calls this directly
no test coverage detected