github.com/wtfutil/wtf@v0.43.0/modules/airbrake/group_info_table.go (about) 1 package airbrake 2 3 import ( 4 "fmt" 5 "strconv" 6 7 "github.com/wtfutil/wtf/view" 8 ) 9 10 type groupInfoTable struct { 11 group *Group 12 propertyMap map[string]string 13 14 colWidth0 int 15 colWidth1 int 16 tableHeight int 17 } 18 19 func newGroupInfoTable(g *Group) *groupInfoTable { 20 propTable := &groupInfoTable{ 21 group: g, 22 23 colWidth0: 20, 24 colWidth1: 51, 25 tableHeight: 15, 26 } 27 28 propTable.propertyMap = propTable.buildPropertyMap() 29 30 return propTable 31 } 32 33 func (propTable *groupInfoTable) buildPropertyMap() map[string]string { 34 propMap := map[string]string{} 35 36 g := propTable.group 37 if g == nil { 38 return propMap 39 } 40 propMap["1. First Seen"] = g.CreatedAt 41 propMap["2. Last Seen"] = g.LastNoticeAt 42 propMap["3. Occurrences"] = strconv.Itoa(int(g.NoticeCount)) 43 propMap["4. Environment"] = g.Context.Environment 44 propMap["5. Severity"] = g.Context.Severity 45 propMap["6. Muted"] = fmt.Sprintf("%v", g.Muted) 46 propMap["7. File"] = g.File() 47 48 return propMap 49 } 50 51 func (propTable *groupInfoTable) render() string { 52 tbl := view.NewInfoTable( 53 []string{"Property", "Value"}, 54 propTable.propertyMap, 55 propTable.colWidth0, 56 propTable.colWidth1, 57 propTable.tableHeight, 58 ) 59 60 return tbl.Render() 61 }