-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogger.go
More file actions
37 lines (30 loc) · 795 Bytes
/
logger.go
File metadata and controls
37 lines (30 loc) · 795 Bytes
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
package gofig
import (
"fmt"
"log"
)
// A Logger can print log items.
type Logger interface {
Print(values ...interface{})
Printf(format string, values ...interface{})
}
// A LoggerFunc is an adapter function allowing regular methods to act as Loggers.
type LoggerFunc func(v ...interface{})
// Print calls the wrapped fn.
func (fn LoggerFunc) Print(v ...interface{}) {
fn(v...)
}
// Printf calls the wrapped fn.
func (fn LoggerFunc) Printf(format string, v ...interface{}) {
fn(fmt.Sprintf(format, v...))
}
// DefaultLogger returns a standard library logger.
func DefaultLogger() Logger {
return LoggerFunc(func(v ...interface{}) {
log.Println(v...)
})
}
// NopLogger is a no operation that does nothing.
func NopLogger() Logger {
return LoggerFunc(func(...interface{}) {})
}