Description
Describe the bug
The BaseRotatingLogger
performs a check to see if it should_rollover(msg), which is an abstract method that invokes the SizedRotatingLogger
function should_rollover(msg). Inside of the should_rollover
function, the writer.tell()
function is utilized to see how large the file being written to is. The issue when the writer
is of type BLFWriter is that writer.tell()
always returns a size of 144 bytes, until the buffer grows to be larger than the max_container_size and the buffer is flushed. Then the function writer.tell()
returns something around 26,500 bytes (25.8 KiB). As long as the -s
option is larger than the header (144 bytes), then the file written will always be around 25.8 KiB.
To Reproduce
Enable virtual can: sudo ip link add dev vcan0 type vcan && sudo ip link set up vcan0
Spam the virtual bus with random can messages 1 ms apart: cangen vcan0 -e -I 18EAFF26 -L i -v -v -v -g 1
Log the virtual bus: python -m can.logger -c vcan0 -i socketcan -b 250000 -f file.blf -s 150
Expected behavior
I expected for a blf
file of size 150 bytes to be written.
Additional context
OS and version: Ubuntu 20.04.4 LTS
Python version: Python 3.7.17
python-can version: b9d9d01
python-can interface/s (if applicable):
Details
I have added print statements in the io/blf.py
and io/logger.py
modules to highlight the bug here: 977e1e0.