-
Notifications
You must be signed in to change notification settings - Fork 20
Add flush to the file write functions #58
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
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.
In the CPython version of this library, StreamHandler
provides a flush()
operation, and so do its subclasses, such as FileHandler
.
I think the user should be able to use flush()
as needed to guarantee that a log entry has been written to a file, but it should be optional. There are use cases where you don't want to always do a flush()
. This change will cause more wear on the flash chips.
Added a https://docs.python.org/3/library/logging.html#logging.shutdown |
How about this? I added a |
I am sorry! I have led you astray. It turns out the that in the CPython impl, If you didn't want this to happen, you can create your own handlers and have it implements a particular strategy. There is a superclass The CPython library has a We try not to add features to the CPython library API, so I'd be reluctant to add If desired, a separate library could be added that would define a non-flushing file handler, not based on |
Sounds good, I have reverted it back to calling |
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 looks good to me.
Thanks for working on this followup @ilikecake!
Updating https://github.com/adafruit/Adafruit_CircuitPython_asyncio to 1.3.2 from 1.3.1: > Merge pull request adafruit/Adafruit_CircuitPython_asyncio#67 from johnnohj/main Updating https://github.com/adafruit/Adafruit_CircuitPython_Logging to 5.3.1 from 5.3.0: > Merge pull request adafruit/Adafruit_CircuitPython_Logging#58 from ilikecake/file_flush_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Sorry for the churn. Further testing of the logging file handlers showed that they needed a
flush()
after thewrite()
command in order for the contents of the log file to be updated in a reasonable time.