github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/cmd/check-markdown/stats.go (about) 1 // 2 // Copyright (c) 2019 Intel Corporation 3 // 4 // SPDX-License-Identifier: Apache-2.0 5 // 6 7 package main 8 9 import ( 10 "fmt" 11 12 "github.com/sirupsen/logrus" 13 ) 14 15 func (d *Doc) showStats() { 16 var counters [LinkTypeCount]int 17 18 linkCount := 0 19 20 for _, linkList := range d.Links { 21 for _, link := range linkList { 22 counters[link.Type]++ 23 linkCount++ 24 } 25 } 26 27 fields := logrus.Fields{ 28 "headings-count": len(d.Headings), 29 "links-count": linkCount, 30 } 31 32 for i, count := range counters { 33 name := LinkType(i).String() 34 35 fieldName := fmt.Sprintf("link-type-%s-count", name) 36 37 fields[fieldName] = count 38 } 39 40 d.Logger.WithFields(fields).Info("Statistics") 41 }