github.com/puellanivis/breton@v0.2.16/lib/glog/stats.go (about) 1 package glog 2 3 import ( 4 "sync/atomic" 5 ) 6 7 // OutputStats tracks the number of output lines and bytes written. 8 type OutputStats struct { 9 lines int64 10 bytes int64 11 } 12 13 // Lines returns the number of lines written. 14 func (s *OutputStats) Lines() int64 { 15 return atomic.LoadInt64(&s.lines) 16 } 17 18 // Bytes returns the number of bytes written. 19 func (s *OutputStats) Bytes() int64 { 20 return atomic.LoadInt64(&s.bytes) 21 } 22 23 func (s *OutputStats) add(n int64) { 24 atomic.AddInt64(&s.lines, 1) 25 atomic.AddInt64(&s.bytes, n) 26 } 27 28 // Stats tracks the number of lines of output and number of bytes 29 // per severity level. Values must be read with atomic.LoadInt64. 30 var Stats struct { 31 Info, Warning, Error OutputStats 32 } 33 34 var severityStats = []*OutputStats{ 35 infoLog: &Stats.Info, 36 warningLog: &Stats.Warning, 37 errorLog: &Stats.Error, 38 }