forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_bosh_logger.go
71 lines (55 loc) · 1.47 KB
/
fake_bosh_logger.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package directorfakes
import (
"fmt"
"time"
)
type Logger struct {
LogCallArgs *[]LogCallArgs
}
type LogCallArgs struct {
LogLevel string
Tag string
Msg string
Args []string
}
func NewFakeLogger(logCalls *[]LogCallArgs) Logger {
return Logger{
LogCallArgs: logCalls,
}
}
func (l Logger) castToString(args []interface{}) []string {
b := make([]string, len(args))
for i := range args {
b[i] = fmt.Sprintf("%s", args[i])
}
return b
}
func (l Logger) logMsg(logLevel, tag, msg string, args []interface{}) {
*l.LogCallArgs = append(*l.LogCallArgs, LogCallArgs{LogLevel: logLevel, Tag: tag, Msg: msg, Args: l.castToString(args)})
}
func (l Logger) Debug(tag, msg string, args ...interface{}) {
l.logMsg("Debug", tag, msg, args)
}
func (l Logger) DebugWithDetails(tag, msg string, args ...interface{}) {
l.logMsg("DebugWithDetails", tag, msg, args)
}
func (l Logger) Info(tag, msg string, args ...interface{}) {
l.logMsg("Info", tag, msg, args)
}
func (l Logger) Warn(tag, msg string, args ...interface{}) {
l.logMsg("Warn", tag, msg, args)
}
func (l Logger) Error(tag, msg string, args ...interface{}) {
l.logMsg("Error", tag, msg, args)
}
func (l Logger) ErrorWithDetails(tag, msg string, args ...interface{}) {
l.logMsg("ErrorWithDetails", tag, msg, args)
}
func (l Logger) HandlePanic(tag string) {}
func (l Logger) ToggleForcedDebug() {}
func (l Logger) Flush() error {
return nil
}
func (l Logger) FlushTimeout(time.Duration) error {
return nil
}