[ENH]: Logging with a color formatter #412

Merged
fraimondo merged 5 commits from enh/color_format into main 2024-12-05 15:50:38 +00:00
fraimondo commented 2024-12-05 09:48:10 +00:00 (Migrated from github.com)

Taking advantage of the xterm-colors... this PR adds colors to logging messages.

Screenshot 2024-12-05 at 10 47 17

It also allows to set the datalad logger to a different level than the one from junifer, allowing to debug junifer without the million debugging messages from datalad.

Taking advantage of the xterm-colors... this PR adds colors to logging messages. ![Screenshot 2024-12-05 at 10 47 17](https://github.com/user-attachments/assets/3cb310ea-87eb-4214-9b46-b567b6ab456e) It also allows to set the datalad logger to a different level than the one from junifer, allowing to debug junifer without the million debugging messages from datalad.
codecov[bot] commented 2024-12-05 09:48:51 +00:00 (Migrated from github.com)

Codecov Report

Attention: Patch coverage is 0% with 70 lines in your changes missing coverage. Please review.

Project coverage is 0.01%. Comparing base (8e4381a) to head (5cdba91).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
junifer/utils/logging.py 0.00% 41 Missing ⚠️
junifer/cli/cli.py 0.00% 15 Missing ⚠️
...er/api/queue_context/gnu_parallel_local_adapter.py 0.00% 7 Missing ⚠️
junifer/api/queue_context/htcondor_adapter.py 0.00% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##            main    #412      +/-   ##
========================================
- Coverage   0.01%   0.01%   -0.01%     
========================================
  Files        133     133              
  Lines       5615    5676      +61     
========================================
  Hits           1       1              
- Misses      5614    5675      +61     
Flag Coverage Δ
docs 100.00% <ø> (ø)
junifer 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...er/api/queue_context/gnu_parallel_local_adapter.py 0.00% <0.00%> (ø)
junifer/api/queue_context/htcondor_adapter.py 0.00% <0.00%> (ø)
junifer/cli/cli.py 0.00% <0.00%> (ø)
junifer/utils/logging.py 0.00% <0.00%> (ø)
## [Codecov](https://app.codecov.io/gh/juaml/junifer/pull/412?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) Report Attention: Patch coverage is `0%` with `70 lines` in your changes missing coverage. Please review. > Project coverage is 0.01%. Comparing base [(`8e4381a`)](https://app.codecov.io/gh/juaml/junifer/commit/8e4381a15e4321b9f816d08d50fa91bca8f7f2dc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) to head [(`5cdba91`)](https://app.codecov.io/gh/juaml/junifer/commit/5cdba9198aede583d8752d708decd79224d147d6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml). > Report is 6 commits behind head on main. | [Files with missing lines](https://app.codecov.io/gh/juaml/junifer/pull/412?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | Patch % | Lines | |---|---|---| | [junifer/utils/logging.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Futils%2Flogging.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci91dGlscy9sb2dnaW5nLnB5) | 0.00% | [41 Missing :warning: ](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | | [junifer/cli/cli.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Fcli%2Fcli.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci9jbGkvY2xpLnB5) | 0.00% | [15 Missing :warning: ](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | | [...er/api/queue\_context/gnu\_parallel\_local\_adapter.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Fapi%2Fqueue_context%2Fgnu_parallel_local_adapter.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci9hcGkvcXVldWVfY29udGV4dC9nbnVfcGFyYWxsZWxfbG9jYWxfYWRhcHRlci5weQ==) | 0.00% | [7 Missing :warning: ](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | | [junifer/api/queue\_context/htcondor\_adapter.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Fapi%2Fqueue_context%2Fhtcondor_adapter.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci9hcGkvcXVldWVfY29udGV4dC9odGNvbmRvcl9hZGFwdGVyLnB5) | 0.00% | [7 Missing :warning: ](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | <details><summary>Additional details and impacted files</summary> [![Impacted file tree graph](https://app.codecov.io/gh/juaml/junifer/pull/412/graphs/tree.svg?width=650&height=150&src=pr&token=5H21JuZXMw&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml)](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) ```diff @@ Coverage Diff @@ ## main #412 +/- ## ======================================== - Coverage 0.01% 0.01% -0.01% ======================================== Files 133 133 Lines 5615 5676 +61 ======================================== Hits 1 1 - Misses 5614 5675 +61 ``` | [Flag](https://app.codecov.io/gh/juaml/junifer/pull/412/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | Coverage Δ | | |---|---|---| | [docs](https://app.codecov.io/gh/juaml/junifer/pull/412/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | `100.00% <ø> (ø)` | | | [junifer](https://app.codecov.io/gh/juaml/junifer/pull/412/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | `0.00% <0.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/juaml/junifer/pull/412?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml) | Coverage Δ | | |---|---|---| | [...er/api/queue\_context/gnu\_parallel\_local\_adapter.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Fapi%2Fqueue_context%2Fgnu_parallel_local_adapter.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci9hcGkvcXVldWVfY29udGV4dC9nbnVfcGFyYWxsZWxfbG9jYWxfYWRhcHRlci5weQ==) | `0.00% <0.00%> (ø)` | | | [junifer/api/queue\_context/htcondor\_adapter.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Fapi%2Fqueue_context%2Fhtcondor_adapter.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci9hcGkvcXVldWVfY29udGV4dC9odGNvbmRvcl9hZGFwdGVyLnB5) | `0.00% <0.00%> (ø)` | | | [junifer/cli/cli.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Fcli%2Fcli.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci9jbGkvY2xpLnB5) | `0.00% <0.00%> (ø)` | | | [junifer/utils/logging.py](https://app.codecov.io/gh/juaml/junifer/pull/412?src=pr&el=tree&filepath=junifer%2Futils%2Flogging.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=juaml#diff-anVuaWZlci91dGlscy9sb2dnaW5nLnB5) | `0.00% <0.00%> (ø)` | | </details>
synchon (Migrated from github.com) requested changes 2024-12-05 10:02:39 +00:00
@ -83,0 +109,4 @@
def __init__(self, fmt: str, datefmt: Optional[str] = None) -> None:
"""Initialize the ColorFormatter."""
logging.Formatter.__init__(self, fmt, datefmt)
synchon (Migrated from github.com) commented 2024-12-05 09:59:26 +00:00

Any preference for range(...) over an IntEnum?

Any preference for `range(...)` over an `IntEnum`?
synchon (Migrated from github.com) commented 2024-12-05 10:02:15 +00:00

What about an option for a --color parameter for switching between the formatters? Maybe some remote machine doesn't have xterm support and that might break it?

What about an option for a `--color` parameter for switching between the formatters? Maybe some remote machine doesn't have xterm support and that might break it?
github-actions[bot] commented 2024-12-05 10:06:03 +00:00 (Migrated from github.com)
PR Preview Action v1.4.8
Preview removed because the pull request was closed.
2024-12-05 16:03 UTC
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) v1.4.8 :---: Preview removed because the pull request was closed. 2024-12-05 16:03 UTC <!-- Sticky Pull Request Commentpr-preview -->
fraimondo (Migrated from github.com) reviewed 2024-12-05 10:12:40 +00:00
@ -83,0 +109,4 @@
def __init__(self, fmt: str, datefmt: Optional[str] = None) -> None:
"""Initialize the ColorFormatter."""
logging.Formatter.__init__(self, fmt, datefmt)
fraimondo (Migrated from github.com) commented 2024-12-05 10:12:40 +00:00

just copilot being copilot

just copilot being copilot
fraimondo (Migrated from github.com) reviewed 2024-12-05 10:41:17 +00:00
fraimondo (Migrated from github.com) commented 2024-12-05 10:41:17 +00:00

I will auto-detect color support

I will auto-detect color support
synchon (Migrated from github.com) reviewed 2024-12-05 10:45:40 +00:00
synchon (Migrated from github.com) commented 2024-12-05 10:45:40 +00:00

Yeah looks good.

Yeah looks good.
synchon (Migrated from github.com) approved these changes 2024-12-05 10:54:37 +00:00
synchon (Migrated from github.com) left a comment

Needs a newsfragment and it's good to go.

Needs a newsfragment and it's good to go.
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
juaml/junifer!412
No description provided.