Skip to content

Compressed SizedRotatingLogger creates files LogReader deems an unknown format #1382

@j-c-cook

Description

@j-c-cook

Describe the bug

The SizedRotatingLogger has an error in the _default_name. When the rollover occurs, files such as file.log_2022-08-27T111103_#000.gz are created. When reading these files with LogReader, a ValueError is thrown, indicating No read support for this unknown log format ".log_2022-08-27t111103_#000".

To Reproduce

Socket CAN setup

Enable CAN interface:

sudo ip link add dev vcan0 type vcan && sudo ip link set up vcan0

Generate random CAN messages 1 millisecond apart:

cangen vcan0 -e -I 18EAFF26 -L i -v -v -v -g 1

python-can setup

python -m can.logger -c vcan0 -i socketcan -b 250000 -f file.blf.gz -s 150000

Use can.logconvert
(pycan) jackcook@rollo:~/Documents/python-can$ python -m can.logconvert file.log_2022-08-27T111103_#000.gz file.log
Traceback (most recent call last):
  File "/home/jackcook/anaconda3/envs/pycan/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/jackcook/anaconda3/envs/pycan/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jackcook/Documents/python-can/can/logconvert.py", line 66, in <module>
    main()
  File "/home/jackcook/Documents/python-can/can/logconvert.py", line 48, in main
    with LogReader(args.input) as reader:
  File "/home/jackcook/Documents/python-can/can/io/player.py", line 91, in __new__
    ) from None
ValueError: No read support for this unknown log format ".log_2022-08-27t111103_#000"

Expected behavior

The SizedRotatingLogger should adequately parse the suffix and create log.gz files.

Additional context

OS and version: Kubuntu 20.04
Python version: 3.7.13
python-can version: pip install git+https://github.com/hardbyte/python-can@2da28c1a1c87776618a60218b0b97800cf2deb34

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions