comparison MoinMoin/server/__init__.py @ 3107:c6e39279f83b

refactor logging usage
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 23 Feb 2008 22:59:30 +0100
parents 80e1a910a2f1
children 4cd113328476
comparison
equal deleted inserted replaced
3106:af3dd2bc85cc 3107:c6e39279f83b
18 def configureLogging(conf, defaults): 18 def configureLogging(conf, defaults):
19 from logging.config import fileConfig 19 from logging.config import fileConfig
20 fileConfig(StringIO(conf), defaults) 20 fileConfig(StringIO(conf), defaults)
21 21
22 def getLogger(name): 22 def getLogger(name):
23 # do we want to strip MoinMoin. from the name?
24 #if name.startswith('MoinMoin.'):
25 # name = name[9:]
23 logger = _logging.getLogger(name) 26 logger = _logging.getLogger(name)
24 for levelnumber, levelname in _logging._levelNames.items(): 27 for levelnumber, levelname in _logging._levelNames.items():
25 if isinstance(levelnumber, int): # that list has also the reverse mapping... 28 if isinstance(levelnumber, int): # that list has also the reverse mapping...
26 setattr(logger, levelname, levelnumber) 29 setattr(logger, levelname, levelnumber)
27 return logger 30 return logger
28 31
29 logging = getLogger('') 32 logging = getLogger(__name__)
33
34 # use this to temporarily and selectively enable debug logging for this module
35 #logging.setLevel(logging.DEBUG)
30 36
31 def switchUID(uid, gid): 37 def switchUID(uid, gid):
32 """ Switch identity to safe user and group 38 """ Switch identity to safe user and group
33 39
34 Does not support Windows, because the necessary calls are not available. 40 Does not support Windows, because the necessary calls are not available.