From 28a066e79a52e116d676e72a1752751b6a1ea7e3 Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Wed, 25 Nov 2020 17:35:19 +0100 Subject: [PATCH] Add timestamp when logging to file Signed-off-by: Julien Riou --- notify-by-telegram.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notify-by-telegram.py b/notify-by-telegram.py index c93c68d..7abe5cc 100755 --- a/notify-by-telegram.py +++ b/notify-by-telegram.py @@ -66,7 +66,8 @@ def validate_config(config): def setup_logging(args): - logging.basicConfig(format='%(levelname)s: %(message)s', level=args.loglevel, filename=args.logfile) + log_format = '%(asctime)s %(levelname)s: %(message)s' if args.logfile else '%(levelname)s: %(message)s' + logging.basicConfig(format=log_format, level=args.loglevel, filename=args.logfile) def markdown_escape(text):