Only enable uuid generation warning when using registry handlers

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2015-07-30 14:00:28 -07:00
parent c737d19235
commit 2c9ab4f441
3 changed files with 6 additions and 9 deletions

View file

@ -29,6 +29,7 @@ import (
_ "github.com/docker/distribution/registry/storage/driver/middleware/cloudfront" _ "github.com/docker/distribution/registry/storage/driver/middleware/cloudfront"
_ "github.com/docker/distribution/registry/storage/driver/s3" _ "github.com/docker/distribution/registry/storage/driver/s3"
_ "github.com/docker/distribution/registry/storage/driver/swift" _ "github.com/docker/distribution/registry/storage/driver/swift"
"github.com/docker/distribution/uuid"
"github.com/docker/distribution/version" "github.com/docker/distribution/version"
gorhandlers "github.com/gorilla/handlers" gorhandlers "github.com/gorilla/handlers"
"github.com/yvasiyarov/gorelic" "github.com/yvasiyarov/gorelic"
@ -62,6 +63,10 @@ func main() {
fatalf("error configuring logger: %v", err) fatalf("error configuring logger: %v", err)
} }
// inject a logger into the uuid library. warns us if there is a problem
// with uuid generation under low entropy.
uuid.Loggerf = context.GetLogger(ctx).Warnf
app := handlers.NewApp(ctx, *config) app := handlers.NewApp(ctx, *config)
handler := configureReporting(app) handler := configureReporting(app)
handler = panicHandler(handler) handler = panicHandler(handler)

View file

@ -3,8 +3,6 @@ package context
import ( import (
"fmt" "fmt"
"github.com/docker/distribution/uuid"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
@ -101,8 +99,3 @@ func getLogrusLogger(ctx Context, keys ...interface{}) *logrus.Entry {
return logger.WithFields(fields) return logger.WithFields(fields)
} }
func init() {
// inject a logger into the uuid library.
uuid.Loggerf = GetLogger(Background()).Warnf
}

View file

@ -8,7 +8,6 @@ import (
"crypto/rand" "crypto/rand"
"fmt" "fmt"
"io" "io"
"log"
"os" "os"
"syscall" "syscall"
"time" "time"
@ -30,7 +29,7 @@ var (
// Loggerf can be used to override the default logging destination. Such // Loggerf can be used to override the default logging destination. Such
// log messages in this library should be logged at warning or higher. // log messages in this library should be logged at warning or higher.
Loggerf = log.Printf Loggerf = func(format string, args ...interface{}) {}
) )
// UUID represents a UUID value. UUIDs can be compared and set to other values // UUID represents a UUID value. UUIDs can be compared and set to other values