开发者

capturing logging messages from imported python file

开发者 https://www.devze.com 2023-04-11 17:38 出处:网络
Getting logging information from an imported python file. I am building a python based test suite. The tests are called using __import function

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

精彩评论

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

关注公众号