Integrate context with storage package

This changeset integrates context with the storage package. Debug messages have
been added to exported methods. Existing log messages will now include
contextual details through logger fields to aid in debugging. This integration
focuses on logging and may be followed up with a metric-oriented change in the
future.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2015-02-09 14:44:58 -08:00
parent d2bfb5825c
commit d9d84ae269
10 changed files with 49 additions and 21 deletions

View file

@ -3,10 +3,10 @@ package storage
import (
"fmt"
"github.com/Sirupsen/logrus"
ctxu "github.com/docker/distribution/context"
"github.com/docker/distribution/digest"
"github.com/docker/distribution/storagedriver"
"golang.org/x/net/context"
)
// TODO(stevvooe): Currently, the blobStore implementation used by the
@ -19,6 +19,7 @@ import (
// backend links.
type blobStore struct {
*registry
ctx context.Context
}
// exists reports whether or not the path exists. If the driver returns error
@ -110,7 +111,7 @@ func (bs *blobStore) resolve(path string) (string, error) {
func (bs *blobStore) put(p []byte) (digest.Digest, error) {
dgst, err := digest.FromBytes(p)
if err != nil {
logrus.Errorf("error digesting content: %v, %s", err, string(p))
ctxu.GetLogger(bs.ctx).Errorf("error digesting content: %v, %s", err, string(p))
return "", err
}