Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log the original calling location, rather than the wrapper function #3257

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

MinchinWeb
Copy link
Contributor

I've noticed that when Pelican logs warnings and errors, the file number and line number are always the same. It turns out we wrap the calling of warnings and errors (but not other logging levels) to allow warnings to be fatal, etc, but it is thus reporting the location of that wrapper function, rather than the "true" caller.

This isn't as helpful as it could be when trying to understand what is going on under the covers.

This is a small patch that allows the logger to show the "true" caller.

Before:

[20:40:37] WARNING  [Seafoam] Development Mode is active. Image Process has been disabled.                     log.py:94
           WARNING  AUTHOR_URL is set to None                                                                  log.py:94
Done: Processed 4 articles, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.51 seconds.

After:

[20:51:24] WARNING  [Seafoam] Development Mode is active. Image Process has been disabled.              initialize.py:51
           WARNING  AUTHOR_URL is set to None                                                         urlwrappers.py:116
Done: Processed 4 articles, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.48 seconds.

The required feature was added in Python 3.8.
c.f. https://stackoverflow.com/a/55998744/4276230

@MinchinWeb
Copy link
Contributor Author

This would fix #3037. C.f. #3038.

@boxydog
Copy link
Contributor

boxydog commented Dec 4, 2023

Cool.

@justinmayer
Copy link
Member

@MinchinWeb: Many thanks for this fix! 👏

@justinmayer justinmayer merged commit af37f06 into getpelican:master Jan 9, 2024
15 checks passed
@MinchinWeb MinchinWeb deleted the real-logging branch January 14, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants