Commit f0eb75f3 authored by Fred Drake's avatar Fred Drake

logging configuration is evil; isolate it

parent 9b836c21
......@@ -603,32 +603,10 @@ def main(module_filter, test_filter, libdir):
if not keepStaleBytecode:
os.path.walk(os.curdir, remove_stale_bytecode, None)
# Get the log.ini file from the current directory instead of possibly
# buried in the build directory. XXX This isn't perfect because if
# log.ini specifies a log file, it'll be relative to the build directory.
# Hmm...
logini = os.path.abspath("log.ini")
# Initialize the path and cwd
global pathinit
pathinit = PathInit(build, build_inplace, libdir)
# Initialize the logging module.
import logging.config
logging.basicConfig()
level = os.getenv("LOGGING")
if level:
level = int(level)
else:
level = logging.CRITICAL
logging.root.setLevel(level)
if os.path.exists(logini):
# Hack: The ZEO tests need to pass the logging config to spawned
# processes. I can't think of a better way to do it than using
# environment variables.
os.environ["LOGINI"] = logini
logging.config.fileConfig(logini)
files = find_tests(module_filter)
files.sort()
......@@ -653,6 +631,33 @@ def main(module_filter, test_filter, libdir):
runner(files, test_filter, debug)
def configure_logging():
"""Initialize the logging module."""
import logging.config
# Get the log.ini file from the current directory instead of possibly
# buried in the build directory. XXX This isn't perfect because if
# log.ini specifies a log file, it'll be relative to the build directory.
# Hmm...
logini = os.path.abspath("log.ini")
if os.path.exists(logini):
logging.config.fileConfig(logini)
else:
logging.basicConfig()
if os.environ.has_key("LOGGING"):
level = int(os.environ["LOGGING"])
logging.getLogger().setLevel(level)
if os.path.exists(logini):
# Hack: The ZEO tests need to pass the logging config to
# spawned processes. We haven't thought of a better way to do
# it than using environment variables.
os.environ["LOGINI"] = logini
logging.config.fileConfig(logini)
def process_args(argv=None):
import getopt
import warnings
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment