util: provide a debugging help

Quick-setting server-side debugging sessions with this
will help a bit.
1 files changed, 8 insertions(+), 0 deletions(-)

M tshistory/util.py
M tshistory/util.py +8 -0
@@ 16,6 16,7 @@ from functools import (
 from contextlib import contextmanager
 from pathlib import Path
 from warnings import warn
+import logging
 
 import pytz
 import numpy as np

          
@@ 26,6 27,13 @@ from sqlalchemy.engine.base import Engin
 from inireader import reader
 
 
+def logme(name, level=logging.DEBUG):
+    logger = logging.getLogger(name)
+    logger.addHandler(logging.StreamHandler())
+    logger.setLevel(level)
+    return logger
+
+
 @contextmanager
 def tempdir(suffix='', prefix='tmp'):
     tmp = tempfile.mkdtemp(suffix=suffix, prefix=prefix)