File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 2828 "PktDrop" , "Drop" ,
2929 "DnsTracking" , "DNS" ,
3030 "FlowRTT" , "RTT" ,
31+ "Dropped" , "Drop" ,
32+ "L3 Layer" , "L3" ,
3133 )
3234)
3335
@@ -461,22 +463,23 @@ func toFieldName(id string) string {
461463 return ""
462464}
463465
464- func ellipsize (text string , maxLen int ) string {
465- if maxLen == 0 {
466+ func ellipsizeAndPad (text string , length int ) string {
467+ if length == 0 {
466468 return text
467469 }
468- lastSpaceIx := maxLen
470+ lastSpaceIx := length
469471 len := 0
472+ truncatedText := text
470473 for i , r := range text {
471474 if unicode .IsSpace (r ) {
472475 lastSpaceIx = i
473476 }
474477 len ++
475- if len > maxLen {
476- return text [:lastSpaceIx ] + "…"
478+ if len > length {
479+ truncatedText = text [:lastSpaceIx ] + "…"
477480 }
478481 }
479- return text
482+ return fmt . Sprintf ( "%-*s" , length , truncatedText )
480483}
481484
482485func ToColWidth (id string ) int {
@@ -502,8 +505,7 @@ func ToColName(id string) string {
502505 name = col .Name
503506 }
504507 }
505- padding := ToColWidth (id )
506- return fmt .Sprintf ("%-*s" , padding , replacer .Replace (name ))
508+ return ellipsizeAndPad (replacer .Replace (name ), ToColWidth (id ))
507509}
508510
509511func ToColValue (genericMap config.GenericMap , id string ) string {
@@ -545,6 +547,5 @@ func ToColValue(genericMap config.GenericMap, id string) string {
545547 outputStr = toValue (genericMap , fieldName )
546548 }
547549
548- width := ToColWidth (id )
549- return ellipsize (outputStr , width )
550+ return ellipsizeAndPad (outputStr , ToColWidth (id ))
550551}
You can’t perform that action at this time.
0 commit comments