Created
March 27, 2024 01:25
-
-
Save Marshall-Hallenbeck/6b03af2ff023c6b6227c48bd3d866dba to your computer and use it in GitHub Desktop.
Print caller name, file, and line number in Pyhton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
caller_name = inspect.stack()[1].function | |
file_name = inspect.stack()[1].filename | |
line_number = inspect.stack()[1].lineno | |
self.logger.debug(f"Called from function: {caller_name} in file {file_name} at line {line_number}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment