Documentation
¶
Overview ¶
Package logtest provides small helpers for tests that assert on the JSON-encoded log file written by the file logging setup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileJSONLogger ¶
NewFileJSONLogger returns a logger that writes JSON encoded records to a log file, together with the path of that file. Read the most recent record back with ReadJSONRecord.
loft-sh/log/logr registers its file sink once per process and rejects a second registration at a different path, so the logger and its file are created on the first call and reused by every later call in this process (other tests in the same package, or the same test under -count=2).
func ReadJSONRecord ¶
ReadJSONRecord reads the log file at path and decodes its last line as a single JSON log record. The file is shared across every NewFileJSONLogger caller in this process, so the last line is the most recently written record rather than necessarily the only one.
Types ¶
This section is empty.