Skip to content

Commit

Permalink
Silence non-error messages by default in the log package
Browse files Browse the repository at this point in the history
But enable printing of non-error messages in main. This provides the
benefits of less noise during tests.
  • Loading branch information
kelseyhightower committed Nov 1, 2013
1 parent e76a67f commit 60285a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion confd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func main() {
// override configuration settings from the cli. Parse the flags now to
// make them active.
flag.Parse()
// non-error messages are not printed by default, enable them now.
// If the "-q" flag was passed on the commandline non-error messages will
// not be printed.
log.SetQuiet(quiet)
log.Info("Starting confd")
if configFile == "" {
Expand All @@ -39,7 +42,8 @@ func main() {
if err := loadConfig(configFile); err != nil {
log.Fatal(err.Error())
}

// Create the etcd client upfront and use it for the life of the process.
// The etcdClient is an http.Client and designed to be reused.
etcdClient, err := newEtcdClient(EtcdNodes(), ClientCert(), ClientKey())
if err != nil {
log.Fatal(err.Error())
Expand Down
4 changes: 2 additions & 2 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
var tag string

// Silence non-error messages.
var quiet bool
var quiet = true

func init() {
tag = os.Args[0]
Expand All @@ -33,7 +33,7 @@ func SetTag(t string) {
tag = t
}

// SetQuiet enables quite mode.
// SetQuiet sets quite mode.
func SetQuiet(q bool) {
quiet = q
}
Expand Down

0 comments on commit 60285a5

Please sign in to comment.