MCPcopy Create free account
hub / github.com/goinaction/code / init

Function init

chapter8/listing11/listing11.go:18–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16)
17
18func init() {
19 file, err := os.OpenFile("errors.txt",
20 os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
21 if err != nil {
22 log.Fatalln("Failed to open error log file:", err)
23 }
24
25 Trace = log.New(ioutil.Discard,
26 "TRACE: ",
27 log.Ldate|log.Ltime|log.Lshortfile)
28
29 Info = log.New(os.Stdout,
30 "INFO: ",
31 log.Ldate|log.Ltime|log.Lshortfile)
32
33 Warning = log.New(os.Stdout,
34 "WARNING: ",
35 log.Ldate|log.Ltime|log.Lshortfile)
36
37 Error = log.New(io.MultiWriter(file, os.Stderr),
38 "ERROR: ",
39 log.Ldate|log.Ltime|log.Lshortfile)
40}
41
42func main() {
43 Trace.Println("I have something standard to say")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected