Add debug-logging-output to tsstats.template.render_template

* bump version to 0.11.1
This commit is contained in:
Thor77 2016-09-18 21:51:24 +02:00
parent 959423be81
commit d1627d369f
2 changed files with 6 additions and 2 deletions

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name='tsstats', name='tsstats',
version='0.11.0', version='0.11.1',
author='Thor77', author='Thor77',
author_email='thor77@thor77.org', author_email='thor77@thor77.org',
description='A simple Teamspeak stats-generator', description='A simple Teamspeak stats-generator',

View File

@ -57,10 +57,14 @@ def render_template(clients, output, title='TeamspeakStats',
def frmttime(timestamp): def frmttime(timestamp):
if not timestamp: if not timestamp:
return '' return ''
return timestamp.strftime(datetime_fmt) formatted = timestamp.strftime(datetime_fmt)
logger.debug('Formatting timestamp %s -> %s', timestamp, formatted)
return formatted
template_env.filters['frmttime'] = frmttime template_env.filters['frmttime'] = frmttime
template = template_env.get_template(template_path) template = template_env.get_template(template_path)
logger.debug('Rendering template %s', template)
with open(output, 'w') as f: with open(output, 'w') as f:
f.write(template.render(title=title, objs=objs, f.write(template.render(title=title, objs=objs,
debug=logger.level <= logging.DEBUG, debug=logger.level <= logging.DEBUG,
creation_time=datetime.now())) creation_time=datetime.now()))
logger.debug('Wrote rendered template to %s', output)