-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample_test.go
93 lines (84 loc) · 2.43 KB
/
example_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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"fmt"
"os"
"github.com/ujiro99/logcatf/logcat"
)
func ExampleLogcatItem_Format_time_message() {
item := &logcat.Entry{
"time": "12-28 19:01:14.073",
"message": "at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)",
}
format := "%t, %m"
formatter = &defaultFormatter{format: &format}
fmt.Println(formatter.Format(item))
// Output:
// 12-28 19:01:14.073, at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)
}
func ExampleLogcatItem_Format_escapedCharactor() {
item := &logcat.Entry{
"time": "12-28 19:01:14.073",
"tag": "GLSUser",
"priority": "W",
"message": "at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)",
}
format := "%t\t%a\t%p\n%m"
formatter = &defaultFormatter{format: &format}
fmt.Println(formatter.Format(item))
// Output:
// 12-28 19:01:14.073 GLSUser W
// at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)
}
func ExampleLogcatItem_Format_priority_missing() {
item := &logcat.Entry{
"time": "12-28 19:01:14.073",
"message": "at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)",
}
format := "%p, %t, %m"
formatter = &defaultFormatter{format: &format}
fmt.Println(formatter.Format(item))
// Output:
// , 12-28 19:01:14.073, at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)
}
func ExampleLogcatItem_Format_all() {
item := &logcat.Entry{
"time": "12-28 19:01:14.073",
"pid": "1836",
"tid": "2720",
"priority": "W",
"tag": "GLSUser",
"message": "at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)",
}
format := "%t, %a, %i, %I, %p, %m"
formatter = &defaultFormatter{format: &format}
fmt.Println(formatter.Format(item))
// Output:
// 12-28 19:01:14.073, GLSUser, 1836, 2720, W, at com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)
}
func ExampleLogcatItem_Format_remainFlags() {
item := &logcat.Entry{
"time": "12-28 19:01:14.073",
"pid": "1",
"tid": "2",
"priority": "W",
"tag": "Tag",
}
format := "%t, %8a, %4i, %-4I,%2p"
formatter = &defaultFormatter{format: &format}
fmt.Println(formatter.Format(item))
// Output:
// 12-28 19:01:14.073, Tag, 1, 2 , W
}
func ExampleLogcatItem_Format_toCsv() {
item := &logcat.Entry{
"pid": "1",
"message": "aaa\"bbb\"ccc",
}
cli := newCli()
cli.outStream = os.Stdout
format := "%m %i"
f := NewCsvFormatter(format)
fmt.Println(f.Format(item))
// Output:
// "aaa""bbb""ccc",1
}