BlfWriter

class BlfWriter(file, compression_level=Compression.NONE, buffer_size=131072)[source]

Bases: AbstractContextManager[BlfWriter]

Binary Log Format (BLF) file writer.

Writes Vector BLF log files with optional compression. Handles automatic buffering and container creation for optimal file structure.

Parameters:
  • file (PathLike[Any]) – Path to BLF file or file-like object

  • compression_level (Compression) – Compression level (0-9), defaults to no compression

  • buffer_size (int) – Size of internal buffer in bytes before flushing, defaults to 128 KiB

Raises:

TypeError – If file parameter is of unsupported type

write(obj)[source]

Write an object to the BLF file.

The object is first buffered and only written to disk when the buffer is full or when the file is closed.

Parameters:

obj (ObjectWithHeader[HeaderWithBase]) – Object to write

Raises:

ValueError – If object size doesn’t match its header

Return type:

None

close()[source]

Close the BLF file.

Flushes any remaining buffered data and updates file statistics before closing.

Return type:

None