diff util.py @ 57:254d5b89a6ca

make sqlalchemy logging configurable through the --databaseLogging commandline parameter
author Dirk Olmes <dirk@xanthippe.ping.de>
date Fri, 23 Jul 2010 04:39:08 +0200
parents 03358c113170
children 04a730f9d07d
line wrap: on
line diff
--- a/util.py	Fri Jul 23 04:06:10 2010 +0200
+++ b/util.py	Fri Jul 23 04:39:08 2010 +0200
@@ -2,12 +2,25 @@
 from datetime import datetime, timedelta
 from Feed import Feed
 import logging
+import sys
 
 logger = logging.getLogger("database")
 
+def databaseLoggingEnabled():
+    loggingEnabled = False
+    for arg in sys.argv:
+        if arg == "--databaseLogging":
+            loggingEnabled = True
+    return loggingEnabled
+
 def configureLogging():
     logging.basicConfig(level=logging.DEBUG)
-    logging.getLogger("sqlalchemy").setLevel(logging.INFO)
+    
+    sqlalchemyLogLevel = logging.ERROR
+    if databaseLoggingEnabled():
+        sqlalchemyLogLevel = logging.INFO
+    logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel)
+    
     logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN)
 
 def loadFeeds(session=None, filename="feeds.txt"):