Skip to content

Commit 26275e4

Browse files
authored
chore: add LOG_XXX constants for lua redis table (#6036)
Signed-off-by: Kostas Kyrimis <[email protected]>
1 parent fa0f64f commit 26275e4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/core/interpreter.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,18 @@ Interpreter::Interpreter() {
708708
lua_pushcfunction(lua_, RedisLogCommand);
709709
lua_settable(lua_, -3);
710710

711+
lua_pushinteger(lua_, LL_DEBUG);
712+
lua_setfield(lua_, -2, "LOG_DEBUG");
713+
714+
lua_pushinteger(lua_, LL_VERBOSE);
715+
lua_setfield(lua_, -2, "LOG_VERBOSE");
716+
717+
lua_pushinteger(lua_, LL_NOTICE);
718+
lua_setfield(lua_, -2, "LOG_NOTICE");
719+
720+
lua_pushinteger(lua_, LL_WARNING);
721+
lua_setfield(lua_, -2, "LOG_WARNING");
722+
711723
/* Finally set the table as 'redis' global var. */
712724
lua_setglobal(lua_, "redis");
713725
CHECK(lua_checkstack(lua_, 64));

src/core/interpreter_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ TEST_F(InterpreterTest, ReplicateCommands) {
493493
TEST_F(InterpreterTest, Log) {
494494
EXPECT_FALSE(Execute(R"(redis.log('nonsense', 'nonsense'))"));
495495
EXPECT_THAT(error_, testing::HasSubstr("First argument must be a number (log level)."));
496-
EXPECT_TRUE(Execute(R"(redis.log(0, 'warn'))"));
496+
EXPECT_TRUE(Execute(R"(redis.log(redis.LOG_WARNING, 'warn'))"));
497497
EXPECT_EQ("nil", ser_.res);
498498
EXPECT_FALSE(Execute(R"(redis.log(4))"));
499499
EXPECT_THAT(error_, testing::HasSubstr("requires two arguments or more"));

0 commit comments

Comments
 (0)