logging tweaks

This commit is contained in:
davemay99 2020-09-24 17:30:50 -04:00
parent 48f8ee1d11
commit 4fcdbb9dee
2 changed files with 4 additions and 3 deletions

View file

@ -15,7 +15,7 @@ import (
func FSMState(p string, plastIdx int64) (interface{}, error) {
store, firstIdx, lastIdx, err := RaftStateInfo(filepath.Join(p, "raft.db"))
if err != nil {
return nil, fmt.Errorf("failed to open raft logs: %v", err)
return nil, fmt.Errorf("failed to open raft database %v: %v", p, err)
}
defer store.Close()
@ -64,7 +64,7 @@ func FSMState(p string, plastIdx int64) (interface{}, error) {
var e raft.Log
err := store.GetLog(i, &e)
if err != nil {
return nil, fmt.Errorf("failed to read log entry at index %d: %v", i, err)
return nil, fmt.Errorf("failed to read log entry at index %d: %v, firstIdx: %d, lastIdx: %d", i, err, firstIdx, lastIdx)
}
if e.Type == raft.LogCommand {
@ -99,6 +99,7 @@ func FSMState(p string, plastIdx int64) (interface{}, error) {
}
func restoreFromSnapshot(fsm raft.FSM, snaps raft.SnapshotStore, logger hclog.Logger) (uint64, error) {
logger = logger.Named("restoreFromSnapshot")
snapshots, err := snaps.List()
if err != nil {
return 0, err

View file

@ -45,7 +45,7 @@ func LogEntries(p string) (logs []interface{}, warnings []error, err error) {
var e raft.Log
err := store.GetLog(i, &e)
if err != nil {
warnings = append(warnings, fmt.Errorf("failed to read log entry at index %d: %v", i, err))
warnings = append(warnings, fmt.Errorf("failed to read log entry at index %d (firstIdx: %d, lastIdx: %d): %v", i, firstIdx, lastIdx, err))
continue
}