1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-11-27 22:18:22 +02:00

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,11 +2,18 @@
import jinja2
import os
convert = lambda src, dst, args: open(dst, "w").write(jinja2.Template(open(src).read()).render(**args))
import logging as log
import sys
args = os.environ.copy()
log.basicConfig(stream=sys.stderr, level=args["LOG_LEVEL"] if "LOG_LEVEL" in args else "WARN")
def convert(src, dst, args):
logger = log.getLogger("convert()")
logger.debug("Source: %s, Destination: %s", src, dst)
open(dst, "w").write(jinja2.Template(open(src).read()).render(**args))
# Get the first DNS server
with open("/etc/resolv.conf") as handle:
content = handle.read().split()