Mutex for debugging deadlocks. It can find non-obvious deadlocks in systems
with heavy sync.Mutex
usage. I found many deadlocks in Docker with it.
type Struct struct {
sync.Locker
}
func New() *Struct {
locker := &sync.Mutex{}
if os.Getenv("DEBUG") != "" {
// will crash program with traceback and file:line where deadlock is
// occured after five tries to acquire mutex with 1 second gap between.
locker = debugmutex.New(5, true)
}
return &Struct{Locker: locker}
}
For logging github.com/sirupsen/logrus
is used. You can set debug logging with
logrus.SetLevel(logrus.DebugLevel)