Implement debug logging for template rendering

This commit is contained in:
Tim Möhlmann
2019-01-08 00:38:06 +02:00
parent e994e94512
commit b04a9d1c28
7 changed files with 47 additions and 9 deletions

View File

@@ -2,8 +2,15 @@
import os
import jinja2
import logging as log
import sys
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
log.basicConfig(stream=sys.stderr, level=os.environ["LOG_LEVEL"] if "LOG_LEVEL" in os.environ else "WARN")
def convert(src, dst):
logger = log.getLogger("convert()")
logger.debug("Source: %s, Destination: %s", src, dst)
open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576))
@@ -14,4 +21,4 @@ os.system("mkdir -p /data/gpg")
os.system("chown -R www-data:www-data /data")
# Run apache
os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])