pkg/log: fix data race on d (#2698)

* pkg/log: fix data race on d

Wrap d in a mutex to prevent data race. This makes is slower, but this
is a debugging aid anyway. It's not used normally.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix tests compilation

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix test compile

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben 2019-05-23 21:02:30 +01:00 committed by GitHub
parent 118b0c9408
commit a84413bd07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 26 deletions

View file

@ -24,7 +24,7 @@ func (p P) log(level string, v ...interface{}) {
// Debug logs as log.Debug.
func (p P) Debug(v ...interface{}) {
if !D {
if !D.Value() {
return
}
p.log(debug, v...)
@ -32,7 +32,7 @@ func (p P) Debug(v ...interface{}) {
// Debugf logs as log.Debugf.
func (p P) Debugf(format string, v ...interface{}) {
if !D {
if !D.Value() {
return
}
p.logf(debug, format, v...)