refactor(ish): extract allocator logging commonality
and add warnf
This commit is contained in:
1 parent
65eff683dd
commit
c48eefa82d
1 file changed
+11
-5
+11
-5
@@ -934,14 +934,20 @@ func (alloc *Allocator) syncOwned(ids map[string]struct{}) {
|
|||||||
// Logging
|
// Logging
|
||||||
|
|
||||||
func (alloc *Allocator) fatalf(fmt string, args ...interface{}) {
|
func (alloc *Allocator) fatalf(fmt string, args ...interface{}) {
|
||||||
common.Log.Fatalf("[allocator %s] "+fmt, append([]interface{}{alloc.ourName}, args...)...)
|
alloc.logf(common.Log.Fatalf, fmt, args...)
|
||||||
|
}
|
||||||
|
func (alloc *Allocator) warnf(fmt string, args ...interface{}) {
|
||||||
|
alloc.logf(common.Log.Warnf, fmt, args...)
|
||||||
}
|
}
|
||||||
func (alloc *Allocator) infof(fmt string, args ...interface{}) {
|
func (alloc *Allocator) infof(fmt string, args ...interface{}) {
|
||||||
common.Log.Infof("[allocator %s] "+fmt, append([]interface{}{alloc.ourName}, args...)...)
|
alloc.logf(common.Log.Infof, fmt, args...)
|
||||||
|
}
|
||||||
|
func (alloc *Allocator) debugf(fmt string, args ...interface{}) {
|
||||||
|
alloc.logf(common.Log.Debugf, fmt, args...)
|
||||||
|
}
|
||||||
|
func (alloc *Allocator) logf(f func(string, ...interface{}), fmt string, args ...interface{}) {
|
||||||
|
f("[allocator %s] "+fmt, append([]interface{}{alloc.ourName}, args...)...)
|
||||||
}
|
}
|
||||||
func (alloc *Allocator) debugln(args ...interface{}) {
|
func (alloc *Allocator) debugln(args ...interface{}) {
|
||||||
common.Log.Debugln(append([]interface{}{fmt.Sprintf("[allocator %s]:", alloc.ourName)}, args...)...)
|
common.Log.Debugln(append([]interface{}{fmt.Sprintf("[allocator %s]:", alloc.ourName)}, args...)...)
|
||||||
}
|
}
|
||||||
func (alloc *Allocator) debugf(fmt string, args ...interface{}) {
|
|
||||||
common.Log.Debugf("[allocator %s] "+fmt, append([]interface{}{alloc.ourName}, args...)...)
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user