File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ int mink_lua_do_perf_set(lua_State *L);
7979int mink_lua_do_perf_match (lua_State * L );
8080int mink_lua_do_db_set (lua_State * L );
8181int mink_lua_do_db_get (lua_State * L );
82+ int mink_lua_log (lua_State * L );
8283
8384// registered lua module methods
8485static const struct luaL_Reg mink_lualib [] = {
@@ -90,6 +91,7 @@ static const struct luaL_Reg mink_lualib[] = {
9091 { "perf_match" , & mink_lua_do_perf_match },
9192 { "db_set" , & mink_lua_do_db_set },
9293 { "db_get" , & mink_lua_do_db_get },
94+ { "log" , & mink_lua_log },
9395 { NULL , NULL }
9496};
9597
Original file line number Diff line number Diff line change @@ -715,3 +715,37 @@ mink_lua_do_db_get(lua_State *L)
715715 return 1 ;
716716}
717717
718+ /*******/
719+ /* log */
720+ /*******/
721+ int
722+ mink_lua_log (lua_State * L )
723+ {
724+ // level, message
725+ if (lua_gettop (L ) < 2 ) {
726+ return 0 ;
727+ }
728+
729+ // string values required
730+ if (!(lua_isstring (L , 1 ) && lua_isstring (L , 2 ))) {
731+ return 0 ;
732+ }
733+
734+ // get values
735+ const char * l = lua_tostring (L , 1 );
736+ const char * m = lua_tostring (L , 2 );
737+
738+ // default level
739+ int i_l = UMD_LLT_INFO ;
740+
741+ if (strcmp (l , "warn" ) == 0 ) {
742+ i_l = UMD_LLT_WARNING ;
743+ } else if (strcmp (l , "error" ) == 0 ) {
744+ i_l = UMD_LLT_ERROR ;
745+ }
746+
747+ umd_log (UMD , i_l , m );
748+
749+ return 0 ;
750+
751+ }
You can’t perform that action at this time.
0 commit comments