add debug option
This commit is contained in:
parent
90bfa04696
commit
1eb8b3b0d6
|
@ -11,12 +11,15 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
{% if debug %}
|
||||
<div class="alert alert-danger" role="alert" style="text-align: center;"><b>DEBUG</b></div>
|
||||
{% endif %}
|
||||
{% for headline, list in objs %}
|
||||
{% if list|length > 0 %}
|
||||
<h1>{{ headline }}</h2>
|
||||
<ul class="list-group">
|
||||
{% for client, value in list %}
|
||||
<li class="list-group-item{{ ' list-group-item-success' if client.connected else loop.cycle('" style="background-color: #eee;', '') }}">{{ client.nick }}<span class="badge">{{ value }}</span></li>
|
||||
<li class="list-group-item{{ ' list-group-item-success' if client.connected else loop.cycle('" style="background-color: #eee;', '') }}">{{ client.nick }}{{ " (" + client.identifier + ")" if debug }}<span class="badge">{{ value }}</span></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
@ -14,7 +14,7 @@ log = logging.getLogger()
|
|||
log.setLevel(logging.DEBUG)
|
||||
# create handler
|
||||
file_handler = logging.FileHandler('debug.txt', 'w', 'UTF-8')
|
||||
file_handler.setFormatter(logging.Formatter('[%(asctime)s] %(message)s', '%d.%m.%Y %H:%M:%S'))
|
||||
file_handler.setFormatter(logging.Formatter('%(message)s'))
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
|
||||
stream_handler = logging.StreamHandler()
|
||||
|
@ -144,7 +144,10 @@ log_path = general['logfile']
|
|||
if not exists(log_path):
|
||||
raise Exception('Couldn\'t access log-file!')
|
||||
output_path = general['outputfile']
|
||||
debug = general.get('debug', 'true') in ['true', 'True']
|
||||
title = html.get('title', 'TeamspeakStats')
|
||||
if not debug:
|
||||
logging.disable(logging.DEBUG)
|
||||
|
||||
generation_start = datetime.datetime.now()
|
||||
|
||||
|
@ -209,4 +212,4 @@ objs = [('Onlinetime', clients_onlinetime), ('Kicks', clients_kicks),
|
|||
('Bans', clients_bans), ('passive Bans', clients_pbans)] # (headline, list)
|
||||
|
||||
with open(output_path, 'w') as f:
|
||||
f.write(template.render(title=title, objs=objs, generation_time='{}.{}'.format(generation_delta.seconds, generation_delta.microseconds), time=generation_end.strftime('%d.%m.%Y %H:%M')))
|
||||
f.write(template.render(title=title, objs=objs, generation_time='{}.{}'.format(generation_delta.seconds, generation_delta.microseconds), time=generation_end.strftime('%d.%m.%Y %H:%M'), debug=debug))
|
||||
|
|
Loading…
Reference in New Issue