k3s/vendor/github.com/Microsoft/hcsshim/internal/hcs/log.go

21 lines
456 B
Go
Raw Normal View History

2019-01-12 04:58:27 +00:00
package hcs
import "github.com/sirupsen/logrus"
func logOperationBegin(ctx logrus.Fields, msg string) {
logrus.WithFields(ctx).Debug(msg)
}
func logOperationEnd(ctx logrus.Fields, msg string, err error) {
2019-07-10 00:29:38 +00:00
// Copy the log and fields first.
log := logrus.WithFields(ctx)
2019-01-12 04:58:27 +00:00
if err == nil {
2019-07-10 00:29:38 +00:00
log.Debug(msg)
2019-01-12 04:58:27 +00:00
} else {
2019-07-10 00:29:38 +00:00
// Edit only the copied field data to avoid race conditions on the
// write.
log.Data[logrus.ErrorKey] = err
log.Error(msg)
2019-01-12 04:58:27 +00:00
}
}