Documentation
¶
Overview ¶
Package logs provides shared log file reading, merging, and following utilities for the Docker Model Runner service log and engine log files created by Docker Desktop.
Index ¶
Constants ¶
const EngineLogName = "inference-llama.cpp-server.log"
EngineLogName is the filename of the DMR engine (llama.cpp) log.
const ServiceLogName = "inference.log"
ServiceLogName is the filename of the DMR service log.
Variables ¶
This section is empty.
Functions ¶
func Follow ¶
func Follow( ctx context.Context, w io.Writer, serviceLogPath string, engineLogPath string, offsets MergeResult, pollMode bool, ) error
Follow tails the service log (and optionally the engine log) from the offsets recorded by a prior MergeLogs call, writing new lines to w until ctx is cancelled.
Using the recorded offsets avoids the gap that would occur if tailing started from the end-of-file: any lines written between the end of MergeLogs and the start of Follow are included.
A single select loop serialises writes from both tail channels so that w does not need to be concurrency-safe (important for http.ResponseWriter).
pollMode should be true on Windows and when accessing files through a mounted filesystem (e.g. WSL2 accessing Windows paths), where filesystem event notifications are unreliable.
func NewHTTPHandler ¶
func NewHTTPHandler(logDir string) http.HandlerFunc
NewHTTPHandler returns an HTTP handler that streams DMR log files from logDir. Only the fixed filenames ServiceLogName and EngineLogName are served; arbitrary paths are not accepted.
Query parameters:
- follow (bool): if true, tail the files after the initial read.
- no-engines (bool): if true, exclude the engine log.
The handler returns:
- 400 if a query parameter cannot be parsed as a boolean.
- 404 if the service log file does not exist.
- 501 if logDir is empty (logs API not configured).
- 200 with Content-Type text/plain on success.
Types ¶
type MergeResult ¶
MergeResult holds the file offsets reached after an initial merge read. Pass these to Follow so it resumes from exactly where the merge left off, with no gap.
func MergeLogs ¶
MergeLogs reads the service log at serviceLogPath and (when engineLogPath is non-empty) the engine log at engineLogPath, merges them in timestamp order, and writes the result to w. It returns the byte offset reached in each file, for use with Follow to avoid missing lines written between the read and the tail start.
A missing or unreadable engine log is tolerated: only the service log is streamed. A missing service log is a hard error.