diff --git a/voussoirkit/operatornotify.py b/voussoirkit/operatornotify.py index d085987..285759e 100644 --- a/voussoirkit/operatornotify.py +++ b/voussoirkit/operatornotify.py @@ -249,7 +249,14 @@ def main_log_context(subject, level, **kwargs): log = vlogging.getLogger() handler = LogHandler(subject, **kwargs) handler.setLevel(level) - handler.setFormatter(vlogging.Formatter('{levelname}:{name}:{message}', style='{')) + datefmt = '%Y-%m-%dT%H:%M:%S' + formatter = vlogging.Formatter( + '[{asctime}.{msecs:03.0f}] {levelname}:{name}:{message}', + style='{', + datefmt=datefmt, + ) + formatter.default_msec_format = '%s.%03d' + handler.setFormatter(formatter) context = LogHandlerContext(log, handler) return context diff --git a/voussoirkit/vlogging.py b/voussoirkit/vlogging.py index e46bdb5..26cf1ed 100644 --- a/voussoirkit/vlogging.py +++ b/voussoirkit/vlogging.py @@ -54,12 +54,15 @@ def add_loud(log): def add_root_handler(level): handler = StreamHandler() + datefmt = '%Y-%m-%dT%H:%M:%S' if level <= LOUD: - handler.setFormatter(Formatter('{levelname}:{name}.{funcName}.{lineno}:{message}', style='{')) + formatter = Formatter('[{asctime}.{msecs:03.0f}] {levelname}:{name}.{funcName}.{lineno}:{message}', style='{', datefmt=datefmt) elif level <= DEBUG: - handler.setFormatter(Formatter('{levelname}:{name}.{funcName}:{message}', style='{')) + formatter = Formatter('[{asctime}.{msecs:03.0f}] {levelname}:{name}.{funcName}:{message}', style='{', datefmt=datefmt) else: - handler.setFormatter(Formatter('{levelname}:{name}:{message}', style='{')) + formatter = Formatter('[{asctime}.{msecs:03.0f}] {levelname}:{name}:{message}', style='{', datefmt=datefmt) + formatter.default_msec_format = '%s.%03d' + handler.setFormatter(formatter) handler.setLevel(level) root.addHandler(handler) return handler