Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

registry.new() support the log function as argument #53

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

prune998
Copy link

@prune998 prune998 commented Jun 1, 2018

now you can call
hub, err := registry.New(*registryURL, *username, *password, log.Infof)
so all the logs will go through your favorit logger, like logrus.
Ex code :

func main() {
	log.Out = os.Stdout
	log.Formatter = new(logrus.JSONFormatter)
	log.Level = logrus.DebugLevel

	flag.Parse()
	hub, err := registry.New(*registryURL, *username, *password, log.Infof)
	if err != nil {
		log.Fatalf("error connecting to hub, %v", err)
	}
...

Ypu can switch log.Level = logrus.DebugLevel to log.Level = logrus.WarnLevel to disable logging

now you can call 
`hub, err := registry.New(*registryURL, *username, *password, log.Infof)`
so all the logs will go through your favorit logger, like logrus.
Ex code : 

```
func main() {
	log.Out = os.Stdout
	log.Formatter = new(logrus.JSONFormatter)
	log.Level = logrus.DebugLevel

	flag.Parse()
	hub, err := registry.New(*registryURL, *username, *password, log.Infof)
	if err != nil {
		log.Fatalf("error connecting to hub, %v", err)
	}
...
```

Ypu can switch `log.Level = logrus.DebugLevel` to `log.Level = logrus.WarnLevel` to disable logging
kispaljr added a commit to nokia/docker-registry-client that referenced this pull request Nov 13, 2018
Fixes issues heroku#42 and heroku#25
Addresses the same problems as heroku#53, heroku#43 and heroku#33, but takes a different a approach
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants