Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于同一函数的每次调用,我需要一个不同的记录器。
loggerA = logging.getLogger('whatever1') myfunction('A') loggerB = logging.getLogger('whatever2') myfunction('B') # The loggers must not cross
我如何为此组织登录 myfunction?可能吗?
你总是可以:
def myfunction(some_arg): logger = logging.getLogger("myfunction." + str(some_arg)) # whatever else
但是,我同意 Vinay 的观点——这是一种反模式!