mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +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"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Error returned if a Producer has run to its end.
|
// 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
|
transparent = true
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
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 {
|
func (db *DecodedBlock) AirOnly() bool {
|
||||||
return db.AirId != -1 && len(db.IndexMap) == 0
|
return db.AirId != -1 && len(db.IndexMap) == 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user