comparison 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
comparison
equal deleted inserted replaced
56:c82f5538733c 57:254d5b89a6ca
1 1
2 from datetime import datetime, timedelta 2 from datetime import datetime, timedelta
3 from Feed import Feed 3 from Feed import Feed
4 import logging 4 import logging
5 import sys
5 6
6 logger = logging.getLogger("database") 7 logger = logging.getLogger("database")
7 8
9 def databaseLoggingEnabled():
10 loggingEnabled = False
11 for arg in sys.argv:
12 if arg == "--databaseLogging":
13 loggingEnabled = True
14 return loggingEnabled
15
8 def configureLogging(): 16 def configureLogging():
9 logging.basicConfig(level=logging.DEBUG) 17 logging.basicConfig(level=logging.DEBUG)
10 logging.getLogger("sqlalchemy").setLevel(logging.INFO) 18
19 sqlalchemyLogLevel = logging.ERROR
20 if databaseLoggingEnabled():
21 sqlalchemyLogLevel = logging.INFO
22 logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel)
23
11 logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN) 24 logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN)
12 25
13 def loadFeeds(session=None, filename="feeds.txt"): 26 def loadFeeds(session=None, filename="feeds.txt"):
14 file = open(filename) 27 file = open(filename)
15 for line in file: 28 for line in file: