logging to a log file with limited size

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
aleskeyfedorovich
Posts: 28
Joined: Mon Aug 27, 2018 4:43 pm

logging to a log file with limited size

Post by aleskeyfedorovich » Tue Mar 30, 2021 10:43 am

I'd like to log to a file appending new lines and when a maximum size is reached removing older lines in favor of new ones such that the log file does not occupy too much memory.
I know this is possibile in python (https://stackoverflow.com/questions/245 ... -in-python).
I'd like to do the same in MicroPython to understand why my script crashes unpredictably.
I've looked at logging in micrpython-lib but I didn't found this feature (https://github.com/micropython/micropyt ... er/logging).
Any help is approciated.
Thank you

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: logging to a log file with limited size

Post by stijn » Tue Mar 30, 2021 11:12 am

This fork has the RotatingFileHandler: https://github.com/pfalcon/pycopy-lib/b ... andlers.py

aleskeyfedorovich
Posts: 28
Joined: Mon Aug 27, 2018 4:43 pm

Re: logging to a log file with limited size

Post by aleskeyfedorovich » Wed Mar 31, 2021 7:21 am

Thank you: I'll try it

Post Reply