forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
39 lines (32 loc) · 743 Bytes
/
log.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
package util
import (
"io"
"github.com/golang/glog"
)
// GetLogLevel returns the current glog log level
func GetLogLevel() (level int) {
for level = 5; level >= 0; level-- {
if glog.V(glog.Level(level)) == true {
break
}
}
return
}
// NewGLogWriterV returns a new Writer that delegates to `glog.Info` at the
// desired level of verbosity
func NewGLogWriterV(level int) io.Writer {
return &gLogWriter{
level: glog.Level(level),
}
}
// gLogWriter is a Writer that writes by delegating to `glog.Info`
type gLogWriter struct {
// level is the default level to log at
level glog.Level
}
func (w *gLogWriter) Write(p []byte) (n int, err error) {
if glog.V(w.level) {
glog.InfoDepth(2, string(p))
}
return len(p), nil
}