MCPcopy
hub / github.com/charmbracelet/bubbletea / LogToFileWith

Function LogToFileWith

logging.go:35–53  ·  view source on GitHub ↗

LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter.

(path string, prefix string, log LogOptionsSetter)

Source from the content-addressed store, hash-verified

33
34// LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter.
35func LogToFileWith(path string, prefix string, log LogOptionsSetter) (*os.File, error) {
36 f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) //nolint:mnd
37 if err != nil {
38 return nil, fmt.Errorf("error opening file for logging: %w", err)
39 }
40 log.SetOutput(f)
41
42 // Add a space after the prefix if a prefix is being specified and it
43 // doesn't already have a trailing space.
44 if len(prefix) > 0 {
45 finalChar := prefix[len(prefix)-1]
46 if !unicode.IsSpace(rune(finalChar)) {
47 prefix += " "
48 }
49 }
50 log.SetPrefix(prefix)
51
52 return f, nil
53}

Callers 1

LogToFileFunction · 0.85

Calls 2

SetOutputMethod · 0.80
SetPrefixMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…