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

add option to not omit identical time values in log renderer #1108

Merged
merged 2 commits into from
Mar 16, 2021
Merged

add option to not omit identical time values in log renderer #1108

merged 2 commits into from
Mar 16, 2021

Conversation

fnep
Copy link
Contributor

@fnep fnep commented Mar 13, 2021

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

I really like the RichHandler for logging, but I find it not so nice that it omits time values if the line above has the same time value. The Main reason is, that I often send snippets of log messages around and then the time is missing because everything happened within a second. My change is a repeat_same_time=True switch to RichHandler (and LogRender) to turn off this behavior.

import logging
from rich.logging import RichHandler

logger = logging.getLogger()
logger.addHandler(RichHandler(repeat_same_time=True))

logger.error("A")
logger.error("B")

Before (or with repeat_same_time=False):

[03/13/21 13:35:55] ERROR    A
                    ERROR    B

After:

[03/13/21 13:36:08] ERROR    A
[03/13/21 13:36:08] ERROR    B

@codecov
Copy link

codecov bot commented Mar 13, 2021

Codecov Report

Merging #1108 (c235db4) into master (9084f33) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1108   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files          67       67           
  Lines        6073     6074    +1     
=======================================
+ Hits         6059     6060    +1     
  Misses         14       14           
Flag Coverage Δ
unittests 99.76% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
rich/logging.py 100.00% <ø> (ø)
rich/_log_render.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c0696a...c235db4. Read the comment docs.

@willmcgugan
Copy link
Collaborator

Thanks. I think it fits better to reverse the bool, i.e. have the default as omit_repeated_times=True.

@fnep
Copy link
Contributor Author

fnep commented Mar 15, 2021

Sure, makes sense. I updated the request in accordance.

@willmcgugan
Copy link
Collaborator

Thanks.

@willmcgugan willmcgugan merged commit 5d716be into Textualize:master Mar 16, 2021
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.

None yet

2 participants