Source File
logutil.go
Belonging Package
src.elv.sh/pkg/logutil
// Package logutil provides logging utilities.package logutilimport ()var (out = ioutil.Discard// If out is set by SetOutputFile, outFile is set and keeps the same value// as out. Otherwise, outFile is nil.outFile *os.Fileloggers []*log.Logger)// GetLogger gets a logger with a prefix.func ( string) *log.Logger {:= log.New(out, , log.LstdFlags)loggers = append(loggers, )return}// SetOutput redirects the output of all loggers obtained with GetLogger to the// new io.Writer. If the old output was a file opened by SetOutputFile, it is// closed.func ( io.Writer) {if outFile != nil {outFile.Close()outFile = nil}out =outFile = nilfor , := range loggers {.SetOutput(out)}}// SetOutputFile redirects the output of all loggers obtained with GetLogger to// the named file. If the old output was a file opened by SetOutputFile, it is// closed. The new file is truncated. SetOutFile("") is equivalent to// SetOutput(ioutil.Discard).func ( string) error {if == "" {SetOutput(ioutil.Discard)return nil}, := os.OpenFile(, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)if != nil {return}SetOutput()outFile =return nil}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)