-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: include filename and line number in logs/errors
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import inspect | ||
|
||
PATTERNS = ["site-packages", "queryspy/listeners.py", "queryspy/patch.py"] | ||
|
||
|
||
def get_caller() -> inspect.FrameInfo: | ||
""" | ||
Returns the filename and line number of the current caller, | ||
excluding any code in site-packages or queryspy. | ||
""" | ||
return next( | ||
frame | ||
for frame in inspect.stack()[1:] | ||
if not any(pattern in frame.filename for pattern in PATTERNS) | ||
) |
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