Browse Source

etcdserver/stats: use leveled log

Xiang Li 10 years ago
parent
commit
f013a627a4
2 changed files with 7 additions and 2 deletions
  1. 1 2
      etcdserver/stats/leader.go
  2. 6 0
      etcdserver/stats/stats.go

+ 1 - 2
etcdserver/stats/leader.go

@@ -16,7 +16,6 @@ package stats
 
 import (
 	"encoding/json"
-	"log"
 	"math"
 	"sync"
 	"time"
@@ -47,7 +46,7 @@ func (ls *LeaderStats) JSON() []byte {
 	b, err := json.Marshal(stats)
 	// TODO(jonboulle): appropriate error handling?
 	if err != nil {
-		log.Printf("stats: error marshalling leader stats: %v", err)
+		plog.Errorf("error marshalling leader stats (%v)", err)
 	}
 	return b
 }

+ 6 - 0
etcdserver/stats/stats.go

@@ -14,6 +14,12 @@
 
 package stats
 
+import "github.com/coreos/pkg/capnslog"
+
+var (
+	plog = capnslog.NewPackageLogger("github.com/coreos/etcd/etcdserver", "stats")
+)
+
 type Stats interface {
 	// SelfStats returns the struct representing statistics of this server
 	SelfStats() []byte