* Simplified logging helper.

* Fixed think-o in how to close the CollectionWrapper inside a ThreadingCollectionWrapper.
This commit is contained in:
David Snopek
2013-07-18 02:17:36 +01:00
parent f891a939c3
commit 9207f3bce4
3 changed files with 30 additions and 16 deletions

View File

@@ -1,15 +1,18 @@
def setup_logging(config_file):
def setup_logging(config_file=None):
"""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
if config_file is not None:
# 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)
# load the config file
import logging.config
logging.config.fileConfig(config_file)
else:
logging.getLogger().setLevel(logging.INFO)