[Zope3-checkins] CVS: Zope3 - test.py:1.97

Fred L. Drake, Jr. fred at zope.com
Thu Apr 8 17:20:31 EDT 2004


Update of /cvs-repository/Zope3
In directory cvs.zope.org:/tmp/cvs-serv15792

Modified Files:
	test.py 
Log Message:
logging configuration is evil; isolate it


=== Zope3/test.py 1.96 => 1.97 ===
--- Zope3/test.py:1.96	Tue Apr  6 17:12:17 2004
+++ Zope3/test.py	Thu Apr  8 17:20:30 2004
@@ -754,28 +754,13 @@
     if not KEEP_STALE_BYTECODE:
         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 os.path.exists(logini):
-        logging.config.fileConfig(logini)
-        if level:
-            logging.root.setLevel(int(level))
-    elif level:
-        logging.root.setLevel(int(level))
+    configure_logging()
 
 ##    try:
 ##        import zLOG
@@ -813,6 +798,25 @@
         runner(files, test_filter, DEBUG)
 
     os.chdir(pathinit.org_cwd)
+
+
+def configure_logging():
+    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)
 
 
 def process_args(argv=None):




More information about the Zope3-Checkins mailing list