...
Source file
src/log/example_test.go
Documentation: log
1
2
3
4
5 package log_test
6
7 import (
8 "bytes"
9 "fmt"
10 "log"
11 )
12
13 func ExampleLogger() {
14 var (
15 buf bytes.Buffer
16 logger = log.New(&buf, "logger: ", log.Lshortfile)
17 )
18
19 logger.Print("Hello, log file!")
20
21 fmt.Print(&buf)
22
23
24 }
25
26 func ExampleLogger_Output() {
27 var (
28 buf bytes.Buffer
29 logger = log.New(&buf, "INFO: ", log.Lshortfile)
30
31 infof = func(info string) {
32 logger.Output(2, info)
33 }
34 )
35
36 infof("Hello world")
37
38 fmt.Print(&buf)
39
40
41 }
42
View as plain text