我想拦截进入 Pythonlogging
框架的字符串,以便我还可以在列表中获得字符串的副本。我希望在每个函数调用上都这样做,因此列表不会在所有调用之间共享。有一些像:
def my_func():
logging.info("some log statement")
def my_func2():
logging.info("some other log statement")
my_func()
logs = logging.get_log()
# Gets every string that got logged in my_func()
my_func2()
logs = logging.get_log()
# Gets every string that got logged in only my_func2()