From bf1b3402ae58e9f0bb97259e8e016c5c8d7841aa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 19:24:11 +0200 Subject: [PATCH] log/template --- rwx/log/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 12fb781..3b245ae 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -7,9 +7,14 @@ import sys def get_file_logger(name: str) -> logging.Logger: """Return a file logger.""" # formatter - formatter = logging.Formatter( - "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", - ) + items = [ + "%(name)s: %(asctime)s", + "%(levelname)s", + "%(filename)s:%(lineno)s", + "%(process)d >>> %(message)s", + ] + template = " | ".join(items) + formatter = logging.Formatter(template) # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setFormatter(formatter)