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

Replace print with loguru #10

Merged
merged 17 commits into from
Apr 29, 2024
Merged

Replace print with loguru #10

merged 17 commits into from
Apr 29, 2024

Conversation

SylviaWhittle
Copy link
Collaborator

@SylviaWhittle SylviaWhittle commented Nov 10, 2023

Closes #2

This PR replaces all the print statements with logging from loguru (colour coded too)

image

@SylviaWhittle SylviaWhittle requested a review from ns-rse November 10, 2023 13:27
Copy link
Collaborator

@ns-rse ns-rse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick and easy implementation. Some comments in-line.

topofileformats/asd.py Outdated Show resolved Hide resolved
topofileformats/asd.py Outdated Show resolved Hide resolved
topofileformats/asd.py Outdated Show resolved Hide resolved
topofileformats/asd.py Outdated Show resolved Hide resolved
@@ -21,6 +23,9 @@
skip_bytes,
)

logger.remove()
logger.add(sys.stderr, format="<white>{time}</white> | <level>{level}</level> | <blue>{message}</blue>")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also pedantically think the main error message should be white, use colour on other sections but the log message are the thing we want to be able to read easiest and they stand out best in consoles when they are white.

Copy link
Collaborator Author

@SylviaWhittle SylviaWhittle Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How's this?

Moved the setup to its own file so we can import topofileformats.logger

image

Copy link
Collaborator

@ns-rse ns-rse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick and easy implementation. Some comments in-line.

@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2023

Codecov Report

Attention: Patch coverage is 78.94737% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 66.76%. Comparing base (f282c31) to head (3dd4f73).
Report is 13 commits behind head on main.

Files Patch % Lines
topofileformats/asd.py 73.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
+ Coverage   65.87%   66.76%   +0.88%     
==========================================
  Files           3        5       +2     
  Lines         337      346       +9     
==========================================
+ Hits          222      231       +9     
  Misses        115      115              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SylviaWhittle SylviaWhittle requested a review from ns-rse November 23, 2023 16:39
Copy link
Collaborator

@ns-rse ns-rse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding the time to continue working on this @SylviaWhittle .

I've one suggestion which is to setup the logger in __init__.py rather than its own file and noticed a very minor tidying to a couple of lines.

topofileformats/logging.py Outdated Show resolved Hide resolved
topofileformats/asd.py Outdated Show resolved Hide resolved
SylviaWhittle and others added 4 commits January 24, 2024 09:37
Co-authored-by: Neil Shephard <[email protected]>
Did some
[reading](https://loguru.readthedocs.io/en/stable/resources/recipes.html#configuring-loguru-to-be-used-by-a-library-or-an-application)
and I was wrong to suggest setting up `loguru` in `__init__.py` so happy to use
`topofileforamts/logging.py`. Implemented the one recommendation in the above linked section. No tests for logging but
logs _are_ output.
@ns-rse ns-rse force-pushed the SylviaWhittle/logging branch from 174035b to e1b1392 Compare April 26, 2024 13:13
@ns-rse ns-rse self-requested a review April 29, 2024 12:30
Copy link
Collaborator

@ns-rse ns-rse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to go @SylviaWhittle 👍

@SylviaWhittle SylviaWhittle merged commit 2fd404e into main Apr 29, 2024
10 checks passed
@ns-rse ns-rse deleted the SylviaWhittle/logging branch May 2, 2024 05:36
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.

Implement logging
3 participants