如何使Logger全局化,以便我可以在我制作的每个模块中使用它?
在moduleA中有类似的东西:
import logging
import moduleB
log = logging.getLogger('')
result = moduleB.goFigure(5)
log.info('Answer was', result)
Run Code Online (Sandbox Code Playgroud)
在moduleB中有了这个:
def goFigure(integer):
if not isinstance(integer, int):
log.critical('not an integer')
else:
return integer + 1
Run Code Online (Sandbox Code Playgroud)
目前,我会收到错误,因为moduleB不知道是什么log.我该如何解决这个问题?