Moved logging into a utils module so we don't have to duplicate it.
This commit is contained in:
parent
f33b655717
commit
1349178157
@ -463,16 +463,10 @@ class CardHandler(RestHandlerBase):
|
|||||||
# Our entry point
|
# Our entry point
|
||||||
def make_app(global_conf, **local_conf):
|
def make_app(global_conf, **local_conf):
|
||||||
# setup the logger
|
# setup the logger
|
||||||
|
from AnkiServer.utils import setup_logging
|
||||||
logging_config_file = local_conf.get('logging.config_file')
|
logging_config_file = local_conf.get('logging.config_file')
|
||||||
if logging_config_file:
|
if logging_config_file:
|
||||||
# monkey patch the logging.config.SMTPHandler if necessary
|
setup_logging(logging_config_file)
|
||||||
import sys
|
|
||||||
if sys.version_info[0] == 2 and sys.version_info[1] == 5:
|
|
||||||
import AnkiServer.logpatch
|
|
||||||
|
|
||||||
# load the config file
|
|
||||||
import logging.config
|
|
||||||
logging.config.fileConfig(logging_config_file)
|
|
||||||
|
|
||||||
return RestApp(
|
return RestApp(
|
||||||
data_root=local_conf.get('data_root', '.'),
|
data_root=local_conf.get('data_root', '.'),
|
||||||
|
|||||||
15
AnkiServer/utils.py
Normal file
15
AnkiServer/utils.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
def setup_logging(config_file):
|
||||||
|
"""Setup logging based on a config_file."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# monkey patch the logging.config.SMTPHandler if necessary
|
||||||
|
import sys
|
||||||
|
if sys.version_info[0] == 2 and sys.version_info[1] == 5:
|
||||||
|
import AnkiServer.logpatch
|
||||||
|
|
||||||
|
# load the config file
|
||||||
|
import logging.config
|
||||||
|
logging.config.fileConfig(config_file)
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user