-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcommon_test.go
36 lines (29 loc) · 892 Bytes
/
common_test.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 zapp
import (
"bufio"
"bytes"
"fmt"
"log"
"os"
"strings"
)
func executeProcessorTest(lines []string, options ...ProcessorOption) *bytes.Buffer {
reader := bytes.NewReader([]byte(strings.Join(lines, "\n")))
writer := &bytes.Buffer{}
processor := &Processor{
scanner: bufio.NewScanner(reader),
output: writer,
multilineJSONFieldThreshold: 3,
}
if os.Getenv("DEBUG") != "" {
options = append(options, WithDebugLogger(log.New(os.Stdout, "[pretty-test] ", 0)))
}
for _, opt := range options {
opt.apply(processor)
}
processor.Process()
return writer
}
func zapdriverLine(severity string, time string) string {
return fmt.Sprintf(`{"severity":"%s","time":"%s","caller":"c:0","message":"m","folder":"f","labels":{},"logging.googleapis.com/sourceLocation":{"file":"f","line":"1","function":"fn"}}`, severity, time)
}