mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-08 03:00:26 +01:00
Log missing colors only once to make log output less spammy.
This commit is contained in:
parent
232feaa435
commit
91a50a4622
|
@ -7,6 +7,7 @@ import (
|
|||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Error returned if a Producer has run to its end.
|
||||
|
@ -163,7 +164,7 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
|||
transparent = true
|
||||
}
|
||||
} else {
|
||||
log.Printf("Missing color entry for %s.", name)
|
||||
logMissing(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,6 +181,20 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
|||
return
|
||||
}
|
||||
|
||||
var missingColors = struct {
|
||||
sync.Mutex
|
||||
cols map[string]struct{}
|
||||
}{cols: map[string]struct{}{}}
|
||||
|
||||
func logMissing(name string) {
|
||||
missingColors.Lock()
|
||||
defer missingColors.Unlock()
|
||||
if _, found := missingColors.cols[name]; !found {
|
||||
missingColors.cols[name] = struct{}{}
|
||||
log.Printf("Missing color entry for %s.\n", name)
|
||||
}
|
||||
}
|
||||
|
||||
func (db *DecodedBlock) AirOnly() bool {
|
||||
return db.AirId != -1 && len(db.IndexMap) == 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user