From 0e84036b1b727356d433373b017204a8d575d2e4 Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 4 Jan 2022 12:17:02 -0600 Subject: add lua logging --- src/bindings.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/bindings.c') 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; +} -- cgit v1.2.1