diff --git a/go/filer/embedded_filer/directory_in_map.go b/go/filer/embedded_filer/directory_in_map.go index a1d0f43bd..1b904c874 100644 --- a/go/filer/embedded_filer/directory_in_map.go +++ b/go/filer/embedded_filer/directory_in_map.go @@ -62,7 +62,7 @@ func NewDirectoryManagerInMap(dirLogFile string) (dm *DirectoryManagerInMap, err //dm.Root do not use NewDirectoryEntryInMap, since dm.max will be changed dm.Root = &DirectoryEntryInMap{SubDirectories: make(map[string]*DirectoryEntryInMap)} if dm.logFile, err = os.OpenFile(dirLogFile, os.O_RDWR|os.O_CREATE, 0644); err != nil { - return nil, fmt.Errorf("cannot write directory log file %s.idx: %s", dirLogFile, err.Error()) + return nil, fmt.Errorf("cannot write directory log file %s.idx: %v", dirLogFile, err) } return dm, dm.load() } diff --git a/go/storage/cdb_map.go b/go/storage/cdb_map.go index fbb59e9c0..1902ea5eb 100644 --- a/go/storage/cdb_map.go +++ b/go/storage/cdb_map.go @@ -214,12 +214,12 @@ func DumpNeedleMapToCdb(cdbName string, nm *NeedleMap) error { func openTempCdb(fileName string) (cdb.AdderFunc, cdb.CloserFunc, error) { fh, err := os.Create(fileName) if err != nil { - return nil, nil, fmt.Errorf("cannot create cdb file %s: %s", fileName, err.Error()) + return nil, nil, fmt.Errorf("cannot create cdb file %s: %v", fileName, err) } adder, closer, err := cdb.MakeFactory(fh) if err != nil { fh.Close() - return nil, nil, fmt.Errorf("error creating factory: %s", err.Error()) + return nil, nil, fmt.Errorf("error creating factory: %v", err) } return adder, func() error { if e := closer(); e != nil { diff --git a/go/storage/needle_map.go b/go/storage/needle_map.go index 504ca1552..98a85b7ab 100644 --- a/go/storage/needle_map.go +++ b/go/storage/needle_map.go @@ -126,7 +126,7 @@ func (nm *NeedleMap) Put(key uint64, offset uint32, size uint32) (int, error) { nm.DeletionByteCounter = nm.DeletionByteCounter + uint64(oldSize) } if _, err := nm.indexFile.Seek(0, 2); err != nil { - return 0, fmt.Errorf("cannot go to the end of indexfile %s: %s", nm.indexFile.Name(), err.Error()) + return 0, fmt.Errorf("cannot go to the end of indexfile %s: %v", nm.indexFile.Name(), err) } return nm.indexFile.Write(bytes) } @@ -141,10 +141,10 @@ func (nm *NeedleMap) Delete(key uint64) error { util.Uint32toBytes(bytes[8:12], 0) util.Uint32toBytes(bytes[12:16], 0) if _, err := nm.indexFile.Seek(0, 2); err != nil { - return fmt.Errorf("cannot go to the end of indexfile %s: %s", nm.indexFile.Name(), err.Error()) + return fmt.Errorf("cannot go to the end of indexfile %s: %v", nm.indexFile.Name(), err) } if _, err := nm.indexFile.Write(bytes); err != nil { - return fmt.Errorf("error writing to indexfile %s: %s", nm.indexFile.Name(), err.Error()) + return fmt.Errorf("error writing to indexfile %s: %v", nm.indexFile.Name(), err) } nm.DeletionCounter++ return nil diff --git a/go/storage/needle_read_write.go b/go/storage/needle_read_write.go index 663b5abbd..36ae2aa85 100644 --- a/go/storage/needle_read_write.go +++ b/go/storage/needle_read_write.go @@ -30,12 +30,12 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, err error) { defer func(s io.Seeker, off int64) { if err != nil { if _, e = s.Seek(off, 0); e != nil { - glog.V(0).Infof("Failed to seek %s back to %d with error: %s", w, off, e.Error()) + glog.V(0).Infof("Failed to seek %s back to %d with error: %v", w, off, e) } } }(s, end) } else { - err = fmt.Errorf("Cnnot Read Current Volume Position: %s", e.Error()) + err = fmt.Errorf("Cnnot Read Current Volume Position: %v", e) return } } diff --git a/go/storage/volume.go b/go/storage/volume.go index a1eccd62c..46d41dc2b 100644 --- a/go/storage/volume.go +++ b/go/storage/volume.go @@ -287,10 +287,10 @@ func ScanVolumeFile(dirname string, collection string, id VolumeId, visitNeedle func(n *Needle, offset int64) error) (err error) { var v *Volume if v, err = loadVolumeWithoutIndex(dirname, collection, id); err != nil { - return errors.New("Failed to load volume:" + err.Error()) + return fmt.Errorf("Failed to load volume %d: %v", id, err) } if err = visitSuperBlock(v.SuperBlock); err != nil { - return errors.New("Failed to read super block:" + err.Error()) + return fmt.Errorf("Failed to read volume %d super block: %v", id, err) } version := v.Version() diff --git a/go/storage/volume_info.go b/go/storage/volume_info.go index bc8049ea4..a7f3acf2b 100644 --- a/go/storage/volume_info.go +++ b/go/storage/volume_info.go @@ -39,5 +39,6 @@ func NewVolumeInfo(m *operation.VolumeInformationMessage) (vi VolumeInfo, err er } func (vi VolumeInfo) String() string { - return fmt.Sprintf("Id:%s, Size:%d, ReplicaPlacement:%s, Collection:%s, Version:%v, FileCount:%d, DeleteCount:%d, DeletedByteCount:%d, ReadOnly:%v", vi.Id, vi.Size, vi.ReplicaPlacement, vi.Collection, vi.Version, vi.FileCount, vi.DeleteCount, vi.DeletedByteCount, vi.ReadOnly) + return fmt.Sprintf("Id:%d, Size:%d, ReplicaPlacement:%s, Collection:%s, Version:%v, FileCount:%d, DeleteCount:%d, DeletedByteCount:%d, ReadOnly:%v", + vi.Id, vi.Size, vi.ReplicaPlacement, vi.Collection, vi.Version, vi.FileCount, vi.DeleteCount, vi.DeletedByteCount, vi.ReadOnly) } diff --git a/go/storage/volume_super_block.go b/go/storage/volume_super_block.go index 57e0deea9..2fb2ed4bf 100644 --- a/go/storage/volume_super_block.go +++ b/go/storage/volume_super_block.go @@ -38,7 +38,7 @@ func (s *SuperBlock) Bytes() []byte { func (v *Volume) maybeWriteSuperBlock() error { stat, e := v.dataFile.Stat() if e != nil { - glog.V(0).Infof("failed to stat datafile %s: %s", v.dataFile, e.Error()) + glog.V(0).Infof("failed to stat datafile %s: %v", v.dataFile, e) return e } if stat.Size() == 0 { @@ -57,11 +57,11 @@ func (v *Volume) maybeWriteSuperBlock() error { } func (v *Volume) readSuperBlock() (err error) { if _, err = v.dataFile.Seek(0, 0); err != nil { - return fmt.Errorf("cannot seek to the beginning of %s: %s", v.dataFile.Name(), err.Error()) + return fmt.Errorf("cannot seek to the beginning of %s: %v", v.dataFile.Name(), err) } header := make([]byte, SuperBlockSize) if _, e := v.dataFile.Read(header); e != nil { - return fmt.Errorf("cannot read superblock: %s", e.Error()) + return fmt.Errorf("cannot read volume %d super block: %v", v.Id, e) } v.SuperBlock, err = ParseSuperBlock(header) return err diff --git a/go/topology/configuration_test.go b/go/topology/configuration_test.go index 35d82c058..0a353d16e 100644 --- a/go/topology/configuration_test.go +++ b/go/topology/configuration_test.go @@ -33,7 +33,7 @@ func TestLoadConfiguration(t *testing.T) { fmt.Printf("%s\n", c) if err != nil { - t.Fatalf("unmarshal error:%s", err.Error()) + t.Fatalf("unmarshal error:%v", err) } if len(c.Topo.DataCenters) <= 0 || c.Topo.DataCenters[0].Name != "dc1" { diff --git a/go/topology/volume_growth.go b/go/topology/volume_growth.go index 6124c0da2..3ad6ad757 100644 --- a/go/topology/volume_growth.go +++ b/go/topology/volume_growth.go @@ -204,7 +204,7 @@ func (vg *VolumeGrowth) grow(topo *Topology, vid storage.VolumeId, option *Volum glog.V(0).Infoln("Created Volume", vid, "on", server) } else { glog.V(0).Infoln("Failed to assign", vid, "to", servers, "error", err) - return fmt.Errorf("Failed to assign %s: %s", vid.String(), err.Error()) + return fmt.Errorf("Failed to assign %d: %v", vid, err) } } return nil diff --git a/go/weed/filer.go b/go/weed/filer.go index 5b3fd2b67..4e7191e34 100644 --- a/go/weed/filer.go +++ b/go/weed/filer.go @@ -77,7 +77,7 @@ func runFiler(cmd *Command, args []string) bool { *f.redis_server, *f.redis_database, ) if nfs_err != nil { - glog.Fatalf(nfs_err.Error()) + glog.Fatalf("Filer startup error: %v", nfs_err) } glog.V(0).Infoln("Start Seaweed Filer", util.VERSION, "at port", strconv.Itoa(*f.port)) filerListener, e := util.NewListener( @@ -85,10 +85,10 @@ func runFiler(cmd *Command, args []string) bool { time.Duration(10)*time.Second, ) if e != nil { - glog.Fatalf(e.Error()) + glog.Fatalf("Filer listener error: %v", e) } if e := http.Serve(filerListener, r); e != nil { - glog.Fatalf("Filer Fail to serve:%s", e.Error()) + glog.Fatalf("Filer Fail to serve: %v", e) } return true diff --git a/go/weed/master.go b/go/weed/master.go index de4b5cb4b..13f6d7c43 100644 --- a/go/weed/master.go +++ b/go/weed/master.go @@ -71,7 +71,7 @@ func runMaster(cmd *Command, args []string) bool { listener, e := util.NewListener(listeningAddress, time.Duration(*mTimeout)*time.Second) if e != nil { - glog.Fatalf(e.Error()) + glog.Fatalf("Master startup error: %v", e) } go func() { @@ -93,7 +93,7 @@ func runMaster(cmd *Command, args []string) bool { }() if e := http.Serve(listener, r); e != nil { - glog.Fatalf("Fail to serve:%s", e.Error()) + glog.Fatalf("Fail to serve: %v", e) } return true } diff --git a/go/weed/server.go b/go/weed/server.go index 1bb0ab0a7..980c545b4 100644 --- a/go/weed/server.go +++ b/go/weed/server.go @@ -167,7 +167,7 @@ func runServer(cmd *Command, args []string) bool { "", 0, ) if nfs_err != nil { - glog.Fatalf(nfs_err.Error()) + glog.Fatalf("Filer startup error: %v", nfs_err) } glog.V(0).Infoln("Start Seaweed Filer", util.VERSION, "at port", strconv.Itoa(*filerOptions.port)) filerListener, e := util.NewListener( @@ -175,10 +175,11 @@ func runServer(cmd *Command, args []string) bool { time.Duration(10)*time.Second, ) if e != nil { + glog.Fatalf("Filer listener error: %v", e) glog.Fatalf(e.Error()) } if e := http.Serve(filerListener, r); e != nil { - glog.Fatalf("Filer Fail to serve:%s", e.Error()) + glog.Fatalf("Filer Fail to serve: %v", e) } }() } @@ -199,7 +200,7 @@ func runServer(cmd *Command, args []string) bool { glog.V(0).Infoln("Start Seaweed Master", util.VERSION, "at", *serverIp+":"+strconv.Itoa(*masterPort)) masterListener, e := util.NewListener(*serverBindIp+":"+strconv.Itoa(*masterPort), time.Duration(*serverTimeout)*time.Second) if e != nil { - glog.Fatalf(e.Error()) + glog.Fatalf("Master startup error: %v", e) } go func() { @@ -235,7 +236,7 @@ func runServer(cmd *Command, args []string) bool { time.Duration(*serverTimeout)*time.Second, ) if e != nil { - glog.Fatalf(e.Error()) + glog.Fatalf("Volume server listener error: %v", e) } OnInterrupt(func() { @@ -244,7 +245,7 @@ func runServer(cmd *Command, args []string) bool { }) if e := http.Serve(volumeListener, r); e != nil { - glog.Fatalf("Fail to serve:%s", e.Error()) + glog.Fatalf("Volume server fail to serve:%v", e) } return true diff --git a/go/weed/volume.go b/go/weed/volume.go index a9f7f508c..1dfd88576 100644 --- a/go/weed/volume.go +++ b/go/weed/volume.go @@ -119,7 +119,7 @@ func runVolume(cmd *Command, args []string) bool { listener, e := util.NewListener(listeningAddress, time.Duration(*v.idleConnectionTimeout)*time.Second) if e != nil { - glog.Fatalf(e.Error()) + glog.Fatalf("Volume server listener error:%v", e) } OnInterrupt(func() { @@ -127,7 +127,7 @@ func runVolume(cmd *Command, args []string) bool { }) if e := http.Serve(listener, r); e != nil { - glog.Fatalf("Fail to serve:%s", e.Error()) + glog.Fatalf("Volume server fail to serve: %v", e) } return true } diff --git a/go/weed/weed_server/common.go b/go/weed/weed_server/common.go index 44ffcce47..d259aa660 100644 --- a/go/weed/weed_server/common.go +++ b/go/weed/weed_server/common.go @@ -61,7 +61,7 @@ func writeJson(w http.ResponseWriter, r *http.Request, httpStatus int, obj inter // wrapper for writeJson - just logs errors func writeJsonQuiet(w http.ResponseWriter, r *http.Request, httpStatus int, obj interface{}) { if err := writeJson(w, r, httpStatus, obj); err != nil { - glog.V(0).Infof("error writing JSON %s: %s", obj, err.Error()) + glog.V(0).Infof("error writing JSON %s: %v", obj, err) } } func writeJsonError(w http.ResponseWriter, r *http.Request, httpStatus int, err error) {