Browse Source

Merge pull request #1421 from xiangli-cmu/logging

*: better logging
Xiang Li 11 years ago
parent
commit
000962d689
3 changed files with 6 additions and 4 deletions
  1. 1 1
      etcdserver/server.go
  2. 2 0
      etcdserver/server_test.go
  3. 3 3
      main.go

+ 1 - 1
etcdserver/server.go

@@ -526,7 +526,7 @@ func (s *EtcdServer) publish(retryInterval time.Duration) {
 		cancel()
 		switch err {
 		case nil:
-			log.Printf("etcdserver: published %+v to the cluster", s.attributes)
+			log.Printf("etcdserver: published %+v to cluster %x", s.attributes, s.Cluster.ID())
 			return
 		case ErrStopped:
 			log.Printf("etcdserver: aborting publish because server is stopped")

+ 2 - 0
etcdserver/server_test.go

@@ -974,6 +974,7 @@ func TestPublish(t *testing.T) {
 	srv := &EtcdServer{
 		id:         1,
 		attributes: Attributes{Name: "node1", ClientURLs: []string{"http://a", "http://b"}},
+		Cluster:    &Cluster{},
 		node:       n,
 		w:          w,
 	}
@@ -1007,6 +1008,7 @@ func TestPublish(t *testing.T) {
 func TestPublishStopped(t *testing.T) {
 	srv := &EtcdServer{
 		node:    &nodeRecorder{},
+		Cluster: &Cluster{},
 		w:       &waitRecorder{},
 		done:    make(chan struct{}),
 		stopped: make(chan struct{}),

+ 3 - 3
main.go

@@ -195,7 +195,7 @@ func startEtcd() {
 		// Start the peer server in a goroutine
 		urlStr := u.String()
 		go func() {
-			log.Print("Listening for peers on ", urlStr)
+			log.Print("etcd: listening for peers on ", urlStr)
 			log.Fatal(http.Serve(l, ph))
 		}()
 	}
@@ -214,7 +214,7 @@ func startEtcd() {
 
 		urlStr := u.String()
 		go func() {
-			log.Print("Listening for client requests on ", urlStr)
+			log.Print("etcd: listening for client requests on ", urlStr)
 			log.Fatal(http.Serve(l, ch))
 		}()
 	}
@@ -266,7 +266,7 @@ func startProxy() {
 
 		host := u.Host
 		go func() {
-			log.Print("Listening for client requests on ", host)
+			log.Print("etcd: proxy listening for client requests on ", host)
 			log.Fatal(http.Serve(l, ph))
 		}()
 	}