开发者

capturing logging messages from imported python file

Getting logging information from an imported python file.

I am building a python based test suite. The tests are called using __import function I would like to capture the logging messages (in tests) in my test application. The logging messages are generated by using the python logging module. How can I do that ? For example in psuedo code:

    for test in testList:  

               # do something
             # Import Test   

             testid = __import__(test)  

             testOut = testid.run(parameter1,parameter2)    

        开发者_JS百科     print "   => Result: %s\n" % testOut            
             # capture logging information from test which imports logging and append to wxpython window


You can easily create a custom logging handler and assign it to the logger used by your module.

See http://docs.python.org/library/logging.html#handler-objects

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜