log/output.go

30 lines
707 B
Go
Raw Normal View History

// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
2023-12-30 20:48:24 -06:00
package log
import (
2023-12-30 20:48:24 -06:00
golanglog "log"
"os"
2023-12-30 20:48:24 -06:00
)
// start writing all the logging to a tmp file
2024-02-12 15:11:22 -06:00
func SetTmpOLD() {
f, err := os.OpenFile("/tmp/guilogfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
2023-12-30 20:48:24 -06:00
if err != nil {
realFatalf("error opening file: %v", err)
2023-12-30 20:48:24 -06:00
}
// hmm. is there a trick here or must this be in main()
// defer f.Close()
golanglog.SetOutput(f)
realPrintln("This is a test log entry")
2023-12-30 20:48:24 -06:00
}
// start writing all the logging to a tmp file
func UnsetTmp() {
golanglog.SetOutput(os.Stdout)
realPrintln("This is a test log entry")
}