-
Notifications
You must be signed in to change notification settings - Fork 633
Modify file_size
help doc string
#1401
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
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #1401 +/- ##
===========================================
- Coverage 66.19% 65.25% -0.95%
===========================================
Files 86 81 -5
Lines 9068 8767 -301
===========================================
- Hits 6003 5721 -282
+ Misses 3065 3046 -19 |
@zariiii9003 Do I have this explanation correct of how the |
can/logger.py
Outdated
help="Maximum file size in bytes. Rotate log file when size threshold " | ||
"is reached.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
This reverts commit 18241ac.
based on input from @zariiii9003
can/io/logger.py
Outdated
# BLFWriter specific | ||
_128_kb = 128 * 1024 | ||
if kwargs.get('max_container_size', 1) and max_bytes > 0: | ||
kwargs['max_container_size'] = \ | ||
_128_kb if max_bytes > _128_kb else max_bytes * 0.1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zariiii9003 This would get rid of the nuance. I'm anticipating that you are not going to like the BLFWriter
specific code inside of the SizedRotatingLogger
constructor, but let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i don't like this here 😄
Also i do not understand what this does tbh, what's the purpose of this? And why is the default value of kwargs.get('max_container_size', 1)
=1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If max_container_size
is not defined then set the max_container_size
. If max_container_size
is not defined then set the value to be 128 kb
unless the file_size
is less than 128 kb
. In that case set the max_container_size
to 10% of the file_size
.
I'm reverting the commits because I agree that its not a good location.
can/io/logger.py
Outdated
# BLFWriter specific | ||
_128_kb = 128 * 1024 | ||
if kwargs.get('max_container_size', 1) and max_bytes > 0: | ||
kwargs['max_container_size'] = \ | ||
_128_kb if max_bytes > _128_kb else max_bytes * 0.1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i don't like this here 😄
Also i do not understand what this does tbh, what's the purpose of this? And why is the default value of kwargs.get('max_container_size', 1)
=1
?
Co-authored-by: zariiii9003 <[email protected]>
This reverts commit 3afb140.
This reverts commit c39719c.
…hon-can into LoggerHelpStatement
@j-c-cook Can i merge this? |
Yes. As long as you think it’s appropriate to have the details contained in the parenthesis. That it does not crowd up the help description printout. I’ve wondered if it’s more than necessary, and if we should just keep it at #1401 (comment). |
There are parameters with longer descriptions so i think it's fine. |
In that case, merge at will.
I do agree that this may be useful, but think it should possibly be apart of a separate PR since we may have some details to resolve. For example, I think it would be useful if the dictionary was in the following format, given that some implementations do work with
Note: #1378 is currently a known open issue relating to the topic. |
This reverts commit b639560.
In hindsight, I'm not sure that the statement, "(or for the case of blf, maximum buffer size before compression and flush to file)" should be in the help doc string for the logger.
The
BLFWriter
file_size
function is a bit more nuanced than is described there. Compression is not accounted for when checking the size of_buffer_size
, and therefore if the rollover is caused by the_buffer_size
being exceeded, then the resulting file created will have a smaller file size than thefile_size
requested. Ifmax_container_size << max_bytes
then the size of the file will approach the specifiedmax_bytes
.BLFWriter
doc string