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/lua-script/script.h | |
parent | cb4f641884ae6104f44967949f9b52a9a72f7baf (diff) |
add lua logging
Diffstat (limited to 'src/lua-script/script.h')
-rw-r--r-- | src/lua-script/script.h | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/lua-script/script.h b/src/lua-script/script.h index e419923..fe92cef 100644 --- a/src/lua-script/script.h +++ b/src/lua-script/script.h @@ -11,7 +11,7 @@ const char *argent_script = " if type(array) ~= 'table' then return nil end\n" "\n" " local transform = transform or function(x) return x end\n" - " \n" + "\n" " local set = {}\n" " for _, element in ipairs(array) do\n" " set[transform(element)] = true\n" @@ -19,6 +19,19 @@ const char *argent_script = " return set\n" " end\n" "\n" + " function set_tostring(set)\n" + " local str = '[empty]'\n" + " for element in pairs(set) do\n" + " if str == '[empty]' then\n" + " str = tostring(element)\n" + " else\n" + " str = str .. '; '.. tostring(element)\n" + " end\n" + " end\n" + "\n" + " return str\n" + " end\n" + "\n" "\n" " function add_end_slash(str)\n" " if type(str) ~= 'string' then return nil end\n" @@ -34,11 +47,14 @@ const char *argent_script = "\n" "\n" " function setup(config)\n" + " argent.log('debug', 'begin setup')\n" + " local fmt = string.format\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" - " layout_directory = add_end_slash(config.layout_directory) or 'layouts/',\n" - " plugin_directory = add_end_slash(config.layout_directory) or 'plugins/',\n" + " layout_directory = add_end_slash(config.layout_directory) or nil,\n" + " plugin_directory = add_end_slash(config.layout_directory) or nil,\n" " exclude = Set(config.exclude, strip_end_slash) or {},\n" " include = Set(config.include, strip_end_slash) or {},\n" " keep = Set(config.keep, strip_end_slash) or {},\n" @@ -46,7 +62,21 @@ const char *argent_script = " rss_include = Set(config.rss_include, strip_end_slash) or {},\n" " }\n" "\n" - " package.path = argent.config.plugin_directory..'?.lua;'..package.path\n" + " argent.log('info', fmt('site directory: %s', argent.config.site_directory))\n" + " argent.log('info', fmt('output directory: %s', argent.config.output_directory))\n" + " argent.log('info', fmt('layout directory: %s', tostring(argent.config.layout_directory)))\n" + " argent.log('info', fmt('plugin directory: %s', tostring(argent.config.plugin_directory)))\n" + "\n" + " argent.log('info', 'exclusions: '..set_tostring(argent.config.exclude))\n" + " argent.log('info', 'inclusions: '..set_tostring(argent.config.include))\n" + " argent.log('info', 'files to keep: '..set_tostring(argent.config.keep))\n" + " argent.log('info', 'noprocess: '..set_tostring(argent.config.noprocess))\n" + " argent.log('info', 'rss files: '..set_tostring(argent.config.rss_include))\n" + "\n" + " if argent.config.plugin_directory then\n" + " package.path = argent.config.plugin_directory..'?.lua;'..package.path\n" + " end\n" + " argent.log('debug', 'end setup')\n" " end\n" "\n" "\n" @@ -106,7 +136,7 @@ const char *argent_script = " function obliterate_directory(dirname, parent)\n" " local dirname = add_end_slash(dirname) or ''\n" " local parent = parent or ''\n" - " \n" + "\n" " if argent.config.keep[dirname] then return true end\n" "\n" " local keep_self = (dirname == '')\n" @@ -205,5 +235,4 @@ const char *argent_script = " end\n" " process_directory()\n" "end\n" - "\n" ;
\ No newline at end of file |