diff options
author | sanine <sanine.not@pm.me> | 2022-01-04 12:17:02 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-01-04 12:17:02 -0600 |
commit | 0e84036b1b727356d433373b017204a8d575d2e4 (patch) | |
tree | 580ba1cf6f3f1a0f984a1f21511ea7d36814394a /src/bindings.c | |
parent | cb4f641884ae6104f44967949f9b52a9a72f7baf (diff) |
add lua logging
Diffstat (limited to 'src/bindings.c')
-rw-r--r-- | src/bindings.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/bindings.c b/src/bindings.c index 8e7d4d5..1e24570 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -321,3 +321,34 @@ int copy_file(lua_State *L) return 0; } + + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int argent_log_lua(lua_State *L) +{ + char *level_string, *message; + hs_parse_args(L, hs_str(level_string), hs_str(message)); + + int level; + + if(strcmp(level_string, "fatal") == 0) + level = FATAL; + else if (strcmp(level_string, "error") == 0) + level = ERROR; + else if (strcmp(level_string, "warn") == 0) + level = WARN; + else if (strcmp(level_string, "info") == 0) + level = INFO; + else if (strcmp(level_string, "debug") == 0) + level = DEBUG; + else if (strcmp(level_string, "trace") == 0) + level = TRACE; + else { + argent_log(WARN, "level '%s' is invalid; defaulting to 'info'", level_string); + level = INFO; + } + + argent_log(level, message); + return 0; +} |