From d910c62c6280e2550775ad4523356f00fb1e6601 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Mon, 25 Nov 2019 21:21:00 +0100 Subject: [PATCH] Include docker container hostname in logger --- restic_volume_backup/log.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/restic_volume_backup/log.py b/restic_volume_backup/log.py index 2992507..20a0684 100644 --- a/restic_volume_backup/log.py +++ b/restic_volume_backup/log.py @@ -1,12 +1,13 @@ import logging +import os import sys logger = logging.getLogger('restic_volume_backup') +HOSTNAME = os.environ['HOSTNAME'] level = logging.INFO logger.setLevel(level) ch = logging.StreamHandler(stream=sys.stdout) ch.setLevel(level) -ch.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) -# ch.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) +ch.setFormatter(logging.Formatter(f'%(asctime)s - {HOSTNAME} - %(name)s - %(levelname)s - %(message)s')) logger.addHandler(ch)