motor MotorClient open_sync will lost tornado pretty logging

In my main.py, I'm using motor:

...
motor_client = motor.MotorClient().open_sync()
...
if __name__ == '__main__':
    ...
    parse_command_line() # call enable_pretty_logging
    ...

Because motor start a private iolloop in open_sync, and ioloop.start may reset logging config:

...
def start(self):
    if not logging.getLogger().handlers:
        ...
        logging.basicConfig()
...

The pretty logging will be lost if you wrote code like me.

So I just hacked commentting logging.basicConfig() to recover my pretty logging.

喜欢这篇文章就分享到微博吧!
留言请发送到
微信公众帐号
“技术派”

修订历史:


知识共享许可协议

关注@好看簿的蚂蚁

探讨技术、设计、人文和商业
相关的创业话题