add some logging

This commit is contained in:
Solvik Blum 2019-08-06 17:59:46 +02:00
parent 99c205ca65
commit cc08300fee
No known key found for this signature in database
GPG key ID: CC12B3DC262B6C47
3 changed files with 92 additions and 12 deletions

23
netbox_agent/logging.py Normal file
View file

@ -0,0 +1,23 @@
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()