-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompat.go
50 lines (42 loc) · 1.05 KB
/
compat.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package log
import (
"fmt"
)
// Printf wraps Infof
func (l *Logger) Printf(msg string, v ...interface{}) {
NewEntry(l).Infof(msg, v...)
}
// Printf wraps Infof
func (e *Entry) Printf(msg string, v ...interface{}) {
e.Infof(msg, v...)
}
// Printf wraps Infof
func Printf(msg string, v ...interface{}) {
Log.Infof(msg, v...)
}
// Println wraps Info
func (l *Logger) Println(v ...interface{}) {
NewEntry(l).Info(v...)
}
// Println wraps Info
func (e *Entry) Println(v ...interface{}) {
e.Info(v...)
}
// Println wraps Info
func Println(v ...interface{}) {
Log.Info(v...)
}
// Sprintlnn => Sprint no newline. This is to get the behavior of how
// fmt.Sprintln where spaces are always added between operands, regardless of
// their type. Instead of vendoring the Sprintln implementation to spare a
// string allocation, we do the simplest thing.
func sprintlnn(args ...interface{}) string {
// fast path for single, simple string
if len(args) == 1 {
if s, ok := args[0].(string); ok {
return s
}
}
msg := fmt.Sprintln(args...)
return msg[:len(msg)-1]
}