DataLogBackgroundWriter
- class wpilog.DataLogBackgroundWriter(*args, **kwargs)
Bases:
DataLogA data log background writer that periodically flushes the data log on a background thread. The data log file is created immediately upon construction with a temporary filename. The file may be renamed at any time using the SetFilename() function.
The lifetime of this object must be longer than any data log entry objects that refer to it.
The data log is periodically flushed to disk. It can also be explicitly flushed to disk by using the Flush() function. This operation is, however, non-blocking.
Overloaded function.
__init__(self: wpilog._wpilog.DataLogBackgroundWriter, dir: str = ‘’, filename: str = ‘’, period: typing.SupportsFloat | typing.SupportsIndex = 0.25, extraHeader: str = ‘’) -> None
Construct a new Data Log. The log will be initially created with a temporary filename.
- Parameters:
dir – directory to store the log
filename – filename to use; if none provided, a random filename is generated of the form “wpilog_{}.wpilog”
period – time between automatic flushes to disk, in seconds; this is a time/storage tradeoff
extraHeader – extra header data
__init__(self: wpilog._wpilog.DataLogBackgroundWriter, write: collections.abc.Callable[[Buffer], None], period: typing.SupportsFloat | typing.SupportsIndex = 0.25, extraHeader: str = ‘’) -> None
Construct a new Data Log that passes its output to the provided function rather than a file. The write function will be called on a separate background thread and may block. The write function is called with an empty data array when the thread is terminating.
- Parameters:
write – write function
period – time between automatic calls to write, in seconds; this is a time/storage tradeoff
extraHeader – extra header data
- flush() None
Explicitly flushes the log data to disk.
- pause() None
Pauses appending of data records to the log. While paused, no data records are saved (e.g. AppendX is a no-op). Has no effect on entry starts / finishes / metadata changes.
- resume() None
Resumes appending of data records to the log. If called after Stop(), opens a new file (with random name if SetFilename was not called after Stop()) and appends Start records and schema data values for all previously started entries and schemas.
- setFilename(filename: str) None
Change log filename.
- Parameters:
filename – filename
- stop() None
Stops appending all records to the log, and closes the log file.