Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marshall-Hallenbeck/6b03af2ff023c6b6227c48bd3d866dba to your computer and use it in GitHub Desktop.
Save Marshall-Hallenbeck/6b03af2ff023c6b6227c48bd3d866dba to your computer and use it in GitHub Desktop.
Print caller name, file, and line number in Pyhton
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