From a026db7389c15eb5a8905e6f04eb3a92bf31f9bc Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 4 Jan 2022 12:40:29 -0600 Subject: improve logging and move per-function logs to TRACE --- src/bindings.c | 8 ++++---- src/lua-script/script.h | 8 ++++++-- src/lua-script/script.lua | 8 ++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/bindings.c b/src/bindings.c index 1e24570..7a94020 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -49,7 +49,7 @@ static void md_callback(const MD_CHAR *html, MD_SIZE size, void *data) int markdown(lua_State *L) { - argent_log(DEBUG, "begin markdown parsing"); + argent_log(TRACE, "begin markdown parsing"); char *markdown_buffer; hs_parse_args(L, hs_str(markdown_buffer)); size_t len = strlen(markdown_buffer); @@ -79,7 +79,7 @@ int markdown(lua_State *L) lua_pushstring(L, data.buf); free(data.buf); - argent_log(DEBUG, "finish markdown parsing"); + argent_log(TRACE, "finish markdown parsing"); return 1; } @@ -91,7 +91,7 @@ static struct dirent *read_dir(lua_State *L, DIR *directory); int scan_directory(lua_State *L) { - argent_log(DEBUG, "begin scan_directory()"); + argent_log(TRACE, "begin scan_directory()"); char *dir_name; hs_parse_args(L, hs_str(dir_name)); @@ -120,7 +120,7 @@ int scan_directory(lua_State *L) } closedir(directory); - argent_log(DEBUG, "end scan_directory()"); + argent_log(TRACE, "end scan_directory()"); return 2; } diff --git a/src/lua-script/script.h b/src/lua-script/script.h index fe92cef..6bd07bb 100644 --- a/src/lua-script/script.h +++ b/src/lua-script/script.h @@ -1,5 +1,6 @@ const char *argent_script = "return function(config)\n" + " local fmt = string.format\n" "\n" " --------------------------------\n" " --\n" @@ -48,8 +49,7 @@ const char *argent_script = "\n" " function setup(config)\n" " argent.log('debug', 'begin setup')\n" - " local fmt = string.format\n" - "\n" + " \n" " argent.config = {\n" " site_directory = add_end_slash(config.site_directory) or 'site/',\n" " output_directory = add_end_slash(config.output_directory) or 'public/',\n" @@ -116,9 +116,11 @@ const char *argent_script = "\n" " function obliterate_file(file, parent)\n" " if argent.config.keep[file] then\n" + " argent.log('debug', fmt('retaining file %q', file))\n" " return true\n" " end\n" "\n" + " argent.log('debug', fmt('removing file %q', file))\n" " os.remove(argent.config.output_directory..parent..file)\n" " return false\n" " end\n" @@ -126,9 +128,11 @@ const char *argent_script = "\n" " function obliterate_dir(dir, parent)\n" " if argent.config.keep[strip_end_slash(dir)] then\n" + " argent.log('debug', fmt('retaining directory %q', dir))\n" " return true\n" " end\n" "\n" + " argent.log('debug', fmt('obliterating files in %q', parent..dir))\n" " return obliterate_directory(dir, parent)\n" " end\n" "\n" diff --git a/src/lua-script/script.lua b/src/lua-script/script.lua index ef2ef8f..ccfe902 100644 --- a/src/lua-script/script.lua +++ b/src/lua-script/script.lua @@ -1,4 +1,5 @@ return function(config) + local fmt = string.format -------------------------------- -- @@ -47,8 +48,7 @@ return function(config) function setup(config) argent.log('debug', 'begin setup') - local fmt = string.format - + argent.config = { site_directory = add_end_slash(config.site_directory) or 'site/', output_directory = add_end_slash(config.output_directory) or 'public/', @@ -115,9 +115,11 @@ return function(config) function obliterate_file(file, parent) if argent.config.keep[file] then + argent.log('debug', fmt('retaining file %q', file)) return true end + argent.log('debug', fmt('removing file %q', file)) os.remove(argent.config.output_directory..parent..file) return false end @@ -125,9 +127,11 @@ return function(config) function obliterate_dir(dir, parent) if argent.config.keep[strip_end_slash(dir)] then + argent.log('debug', fmt('retaining directory %q', dir)) return true end + argent.log('debug', fmt('obliterating files in %q', parent..dir)) return obliterate_directory(dir, parent) end -- cgit v1.2.1