add logging to device block service (#425)

This commit is contained in:
Victor Vrantchan
2018-05-29 07:41:57 -04:00
committed by GitHub
parent dcd0ec4a41
commit 1916f2a2f5
4 changed files with 55 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"net/http"
"net/url"
"time"
"github.com/go-kit/kit/endpoint"
"github.com/gorilla/mux"
@@ -70,3 +71,17 @@ func (e Endpoints) BlockDevice(ctx context.Context, udid string) error {
}
return resp.(blockDeviceResponse).Err
}
func (mw logmw) BlockDevice(ctx context.Context, udid string) (err error) {
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "BlockDevice",
"udid", udid,
"err", err,
"took", time.Since(begin),
)
}(time.Now())
err = mw.next.BlockDevice(ctx, udid)
return
}