-
Notifications
You must be signed in to change notification settings - Fork 1
/
logutil.go
36 lines (32 loc) · 927 Bytes
/
logutil.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Package logutil provides functions that can print to a logger.
// Any function in this package that takes in a *log.Logger can be
// passed nil to use the log package's default logger.
package logutil
import "log"
// Print calls Print on a logger or the default logger.
// Arguments are handled in the manner of fmt.Print.
func Print(l *log.Logger, v ...interface{}) {
if l == nil {
log.Print(v...)
} else {
l.Print(v...)
}
}
// Printf calls Printf on a logger or the default logger.
// Arguments are handled in the manner of fmt.Printf.
func Printf(l *log.Logger, format string, v ...interface{}) {
if l == nil {
log.Printf(format, v...)
} else {
l.Printf(format, v...)
}
}
// Println calls Println on a logger or the default logger.
// Arguments are handled in the manner of fmt.Println.
func Println(l *log.Logger, v ...interface{}) {
if l == nil {
log.Println(v...)
} else {
l.Println(v...)
}
}