mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
wal: use leveled logger
This commit is contained in:
parent
8825af47a0
commit
185d2bced4
@ -17,7 +17,6 @@ package wal
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/etcd/pkg/fileutil"
|
||||
@ -43,7 +42,7 @@ func searchIndex(names []string, index uint64) (int, bool) {
|
||||
name := names[i]
|
||||
_, curIndex, err := parseWalName(name)
|
||||
if err != nil {
|
||||
log.Panicf("parse correct name should never fail: %v", err)
|
||||
logger.Panicf("parse correct name should never fail: %v", err)
|
||||
}
|
||||
if index >= curIndex {
|
||||
return i, true
|
||||
@ -59,7 +58,7 @@ func isValidSeq(names []string) bool {
|
||||
for _, name := range names {
|
||||
curSeq, _, err := parseWalName(name)
|
||||
if err != nil {
|
||||
log.Panicf("parse correct name should never fail: %v", err)
|
||||
logger.Panicf("parse correct name should never fail: %v", err)
|
||||
}
|
||||
if lastSeq != 0 && lastSeq != curSeq-1 {
|
||||
return false
|
||||
@ -73,7 +72,7 @@ func checkWalNames(names []string) []string {
|
||||
wnames := make([]string, 0)
|
||||
for _, name := range names {
|
||||
if _, _, err := parseWalName(name); err != nil {
|
||||
log.Printf("wal: ignored file %v in wal", name)
|
||||
logger.Warningf("ignored file %v in wal", name)
|
||||
continue
|
||||
}
|
||||
wnames = append(wnames, name)
|
||||
|
10
wal/wal.go
10
wal/wal.go
@ -19,7 +19,6 @@ import (
|
||||
"fmt"
|
||||
"hash/crc32"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
@ -31,6 +30,8 @@ import (
|
||||
"github.com/coreos/etcd/raft"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/wal/walpb"
|
||||
|
||||
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -49,6 +50,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
logger = capnslog.NewPackageLogger("github.com/coreos/etcd", "wal")
|
||||
|
||||
ErrMetadataConflict = errors.New("wal: conflicting metadata found")
|
||||
ErrFileNotFound = errors.New("wal: file not found")
|
||||
ErrCRCMismatch = errors.New("wal: crc mismatch")
|
||||
@ -172,7 +175,7 @@ func openAtIndex(dirpath string, snap walpb.Snapshot, all bool) (*WAL, error) {
|
||||
if all {
|
||||
return nil, err
|
||||
} else {
|
||||
log.Printf("wal: opened all the files until %s, since it is still in use by an etcd server", name)
|
||||
logger.Warningf("opened all the files until %s, since it is still in use by an etcd server", name)
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -353,8 +356,7 @@ func (w *WAL) cut() error {
|
||||
// increase the wal seq
|
||||
w.seq++
|
||||
|
||||
log.Printf("wal: segmented wal file %v is created", fpath)
|
||||
|
||||
logger.Infof("segmented wal file %v is created", fpath)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user