netbox-agent/netbox_agent/logging.py
2019-08-06 18:11:26 +02:00

23 lines
508 B
Python

import logging
def init_log():
logger = logging.getLogger('netbox_agent')
logger.setLevel(logging.DEBUG)
logger_formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
fh = logging.FileHandler('netbox.log')
fh.setLevel(logging.DEBUG)
fh.setFormatter(logger_formatter)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(logger_formatter)
logger.addHandler(fh)
logger.addHandler(ch)
return logger
logger = init_log()