-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata.go
45 lines (34 loc) · 839 Bytes
/
data.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
package chromelogger
const VERSION = "0.1.0"
type LogData []interface{}
func (data *LogData) Add(item interface{}) {
*data = append(*data, item)
}
type LogRow []interface{}
func NewLogRow(logData *LogData, backtrace, logType string) *LogRow {
row := LogRow{
logData,
backtrace,
logType,
}
return &row
}
type Data struct {
Version string `json:"version"`
Columns []string `json:"columns"`
Rows []*LogRow `json:"rows"`
}
func (data *Data) AddRow(item interface{}, backtrace, logType string) {
logData := make(LogData, 0)
logData.Add(item)
row := NewLogRow(&logData, backtrace, logType)
data.Rows = append(data.Rows, row)
}
func NewData() *Data {
data := &Data{
Version: VERSION,
Columns: []string{"log", "backtrace", "type"},
}
data.Rows = make([]*LogRow, 0)
return data
}