Was just looking at the logging docs in Python and came across funcName as a parameter in the log formatter.
While it looks handy, great way to see exactly where the log is coming from obviously, someone’s raised a concern about it, possibly that it would need to generate a stack trace that would be a performance hit.
I assume it uses something like sys._getframe() and not the inspect module, which would have an impact in performance.
Is funcName something we could use in a production environment or should we stay away?
Resist the temptation to guess, the source for logging is available to you as part of your Python distribution.
How it finds the function name (
logging/__init__.py):and then later:
also, no need to worry about the overhead: it figures out the function name before it works out whether or not you needed it so you might as well use it.