JSON lines record logger.
Logs records as JSON strings per line to a file.
Parameters:
Source code in taps/record.py
| def __init__(self, filepath: pathlib.Path | str) -> None:
self._filepath = pathlib.Path(filepath)
self._handle = open(self._filepath, 'a') # noqa: SIM115
|
log
Log a record.
Source code in taps/record.py
| def log(self, record: Record) -> None:
"""Log a record."""
self._handle.write(json.dumps(record) + '\n')
|
close
Close the logger.
Source code in taps/record.py
| def close(self) -> None:
"""Close the logger."""
self._handle.close()
|