From a1f25648a2c9967ac7491c428768c5085d6dfae8 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Wed, 25 May 2016 20:08:48 +0200 Subject: [PATCH] define log_format just once and rename to log_timestamp_format --- docs/source/conf.py | 2 +- setup.py | 2 +- tsstats/log.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 95fa737..74f8bfd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -56,7 +56,7 @@ author = 'Thor77' # The short X.Y version. version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.5.1' +release = '0.5.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 191b680..4d74c07 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='tsstats', - version='0.5.1', + version='0.5.2', author='Thor77', author_email='thor77@thor77.org', description='A simple Teamspeak stats-generator', diff --git a/tsstats/log.py b/tsstats/log.py index 6ef6597..4da2f8c 100644 --- a/tsstats/log.py +++ b/tsstats/log.py @@ -13,6 +13,8 @@ re_disconnect_invoker = re.compile( r'invokername=(.*)\ invokeruid=(.*)\ reasonmsg' ) +log_timestamp_format = '%Y-%m-%d %H:%M:%S.%f' + logger = logging.getLogger('tsstats') @@ -36,8 +38,8 @@ def parse_log(log_path, ident_map=None, clients=None): logger.debug('No match: "%s"', line) continue match = match.groupdict() - log_format = '%Y-%m-%d %H:%M:%S.%f' - stripped_time = datetime.strptime(match['timestamp'], log_format) + stripped_time = datetime.strptime(match['timestamp'], + log_timestamp_format) logdatetime = int((stripped_time - datetime(1970, 1, 1)) .total_seconds()) message = match['message']