开发者

Trying to provide a global logging function

I typically write my scripts with a structure like s

#!/usr/bin/python

import stuff

def do_things():
    print "FOO"

def main():
    do_things()

if __name__ == "__main__":
    main()

The problem I have is I'd like to have a logging function that is defined globally and I"m not really sure how to开发者_StackOverflow do this. I tried a decorator function but if I define it in main I can't call it from other functions in the script. It seems like something that should be easy to do but not something I have experience with.


import logging

Python's logging library should satisfy your requirements.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜