Skip to content

Commit

Permalink
feat(log): add method to set ident
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Dec 16, 2023
1 parent c933577 commit 775906d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ log.debug('eco')
log.info('eco')
log.err('eco')

log.set_ident(arg[0])

-- default is log.INFO
log.set_level(log.DEBUG)

Expand Down
2 changes: 1 addition & 1 deletion log
Submodule log updated 2 files
+40 −19 log.c
+1 −0 log.h
10 changes: 10 additions & 0 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ static int lua_log_set_flags(lua_State *L)
return 0;
}

static int lua_log_set_ident(lua_State *L)
{
const char *ident = luaL_checkstring(L, 1);

set_log_ident(ident);

return 0;
}

static const luaL_Reg funcs[] = {
{"set_level", lua_log_set_level},
{"debug", lua_log_debug},
Expand All @@ -147,6 +156,7 @@ static const luaL_Reg funcs[] = {
{"log", lua_log},
{"set_path", lua_log_set_path},
{"set_flags", lua_log_set_flags},
{"set_ident", lua_log_set_ident},
{NULL, NULL}
};

Expand Down

0 comments on commit 775906d

Please sign in to comment.