mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-22 12:34:17 +00:00
web/lib/utils.py: add check_logger_options()
We need to check config options for logger in various scripts, and this check is almost same, so move it to separate function.
This commit is contained in:
parent
0c8968f31e
commit
891472cfac
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
from logging import handlers
|
from logging import handlers
|
||||||
|
|
||||||
@ -25,3 +26,17 @@ def get_logger(filename=None, log_level='debug'):
|
|||||||
|
|
||||||
return logger
|
return logger
|
||||||
|
|
||||||
|
|
||||||
|
def check_logger_options(config):
|
||||||
|
""" Check passed config for logger options """
|
||||||
|
if 'log_level' in config:
|
||||||
|
log_level = config['log_level']
|
||||||
|
else:
|
||||||
|
sys.stderr.write('"log_level" is missing in config\n')
|
||||||
|
sys.exit(1)
|
||||||
|
if 'log_file' in config:
|
||||||
|
log_file = config['log_file']
|
||||||
|
else:
|
||||||
|
sys.stderr.write('"log_file is missing in config\n')
|
||||||
|
sys.exit(1)
|
||||||
|
return (log_file, log_level)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user