你可以帮我解决Python 2.5和2.6之间的不兼容性问题吗?
logger.conf:
[loggers]
keys=root,aLogger,bLogger
[handlers]
keys=consoleHandler
[formatters]
keys=
[logger_root]
level=NOTSET
handlers=consoleHandler
[logger_aLogger]
level=DEBUG
handlers=consoleHandler
propagate=0
qualname=a
[logger_bLogger]
level=INFO
handlers=consoleHandler
propagate=0
qualname=b
[handler_consoleHandler]
class=StreamHandler
args=(sys.stderr,)
module_one.py:
import logging
import logging.config
logging.config.fileConfig('logger.conf')
a_log = logging.getLogger('a.submod')
b_log = logging.getLogger('b.submod')
def function_one():
b_log.info("function_one() called.")
module_two.py:
import logging
import logging.config
logging.config.fileConfig('logger.conf')
a_log = logging.getLogger('a.submod')
b_log = logging.getLogger('b.submod')
def function_two():
a_log.info("function_two() called.")
logger.py:
from module_one import function_one
from module_two import function_two
function_one()
function_two()
在Ubuntu 9.04下调用logger.py的输出:
$ python2.5 logger.py
$
$ python2.6 logger.py
function_one() called.
function_two() called.
$