improve logging: better for cronjob with stderr output
This commit is contained in:
parent
cafe502551
commit
d79c008a5d
1 changed files with 17 additions and 0 deletions
|
|
@ -1,9 +1,26 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
from netbox_agent.config import config
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
#match support only from python 3.10, our instances still have instance run python 3.9
|
||||
# match config.log_level.lower():
|
||||
# case 'debug':
|
||||
# logger.setLevel(logging.DEBUG)
|
||||
# case 'info':
|
||||
# logger.setLevel(logging.INFO)
|
||||
# case 'warning':
|
||||
# logger.setLevel(logging.WARNING)
|
||||
# case 'error':
|
||||
# logger.setLevel(logging.ERROR)
|
||||
if config.log_level.lower() == 'debug':
|
||||
logger.setLevel(logging.DEBUG)
|
||||
elif config.log_level.lower() == 'warning':
|
||||
logger.setLevel(logging.WARNING)
|
||||
elif config.log_level.lower() == 'error':
|
||||
logger.setLevel(logging.ERROR)
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
# logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S',level=logging.ERROR)
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue