开发者

how to use logging inside Gevent?

开发者 https://www.devze.com 2023-04-08 15:57 出处:网络
开发者_如何转开发I have a code like: log = logging.getLogger(__file__) def func(): print \"1\" log.debug(\"Printed\")

开发者_如何转开发I have a code like:

log = logging.getLogger(__file__)

def func():
    print "1"
    log.debug("Printed")

g = gevent.spawn(func)
g.join()

but when I ran it my log doesn't show in shell. Any ideas? Is there a better way to do logging inside gevent based coroutines?


It is unrelated to gevent. You should configure logging e.g.,

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(msg)s")
0

精彩评论

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