Include docker container hostname in logger
This commit is contained in:
parent
a35814fd2d
commit
d910c62c62
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue