MCPcopy Create free account
hub / github.com/charmbracelet/bubbletea / TestLogToFile

Function TestLogToFile

logging_test.go:10–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestLogToFile(t *testing.T) {
11 path := filepath.Join(t.TempDir(), "log.txt")
12 prefix := "logprefix"
13 f, err := LogToFile(path, prefix)
14 if err != nil {
15 t.Error(err)
16 }
17 log.SetFlags(log.Lmsgprefix)
18 log.Println("some test log")
19 if closeErr := f.Close(); closeErr != nil {
20 t.Error(closeErr)
21 }
22 out, err := os.ReadFile(path)
23 if err != nil {
24 t.Error(err)
25 }
26 if string(out) != prefix+" some test log\n" {
27 t.Fatalf("wrong log msg: %q", string(out))
28 }
29}

Callers

nothing calls this directly

Calls 3

LogToFileFunction · 0.85
PrintlnMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected