Skip to content

Commit

Permalink
Only enable uuid generation warning when using registry handlers
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen J Day <stephen.day@docker.com>
  • Loading branch information
stevvooe committed Jul 30, 2015
1 parent c737d19 commit 7159de6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 5 additions & 0 deletions cmd/registry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
_ "github.com/docker/distribution/registry/storage/driver/middleware/cloudfront"
_ "github.com/docker/distribution/registry/storage/driver/s3"
_ "github.com/docker/distribution/registry/storage/driver/swift"
"github.com/docker/distribution/uuid"
"github.com/docker/distribution/version"
gorhandlers "github.com/gorilla/handlers"
"github.com/yvasiyarov/gorelic"
Expand Down Expand Up @@ -62,6 +63,10 @@ func main() {
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)
handler := configureReporting(app)
handler = panicHandler(handler)
Expand Down
7 changes: 0 additions & 7 deletions context/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package context
import (
"fmt"

"github.com/docker/distribution/uuid"

"github.com/Sirupsen/logrus"
)

Expand Down Expand Up @@ -101,8 +99,3 @@ func getLogrusLogger(ctx Context, keys ...interface{}) *logrus.Entry {

return logger.WithFields(fields)
}

func init() {
// inject a logger into the uuid library.
uuid.Loggerf = GetLogger(Background()).Warnf
}
3 changes: 1 addition & 2 deletions uuid/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"crypto/rand"
"fmt"
"io"
"log"
"os"
"syscall"
"time"
Expand All @@ -30,7 +29,7 @@ var (

// Loggerf can be used to override the default logging destination. Such
// log messages in this library should be logged at warning or higher.
Loggerf = log.Printf
Loggerf func(format string, args ...interface{}) = func(format string, args ...interface{}) {}
)

// UUID represents a UUID value. UUIDs can be compared and set to other values
Expand Down

0 comments on commit 7159de6

Please sign in to comment.