mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-15 20:06:19 +08:00
switching to temporarily use glog library
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"bytes"
|
||||
"code.google.com/p/weed-fs/go/storage"
|
||||
"fmt"
|
||||
"log"
|
||||
"code.google.com/p/weed-fs/go/glog"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
@@ -67,7 +67,7 @@ func runExport(cmd *Command, args []string) bool {
|
||||
fh = os.Stdout
|
||||
} else {
|
||||
if fh, err = os.Create(*dest); err != nil {
|
||||
log.Fatalf("cannot open output tar %s: %s", *dest, err)
|
||||
glog.Fatalf("cannot open output tar %s: %s", *dest, err)
|
||||
}
|
||||
}
|
||||
defer fh.Close()
|
||||
@@ -84,13 +84,13 @@ func runExport(cmd *Command, args []string) bool {
|
||||
vid := storage.VolumeId(*exportVolumeId)
|
||||
indexFile, err := os.OpenFile(path.Join(*exportVolumePath, fileName+".idx"), os.O_RDONLY, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("Create Volume Index [ERROR] %s\n", err)
|
||||
glog.Fatalf("Create Volume Index [ERROR] %s\n", err)
|
||||
}
|
||||
defer indexFile.Close()
|
||||
|
||||
nm, err := storage.LoadNeedleMap(indexFile)
|
||||
if err != nil {
|
||||
log.Fatalf("cannot load needle map from %s: %s", indexFile, err)
|
||||
glog.Fatalf("cannot load needle map from %s: %s", indexFile, err)
|
||||
}
|
||||
|
||||
var version storage.Version
|
||||
@@ -113,7 +113,7 @@ func runExport(cmd *Command, args []string) bool {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Export Volume File [ERROR] %s\n", err)
|
||||
glog.Fatalf("Export Volume File [ERROR] %s\n", err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"code.google.com/p/weed-fs/go/storage"
|
||||
"log"
|
||||
"code.google.com/p/weed-fs/go/glog"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
@@ -35,7 +35,7 @@ func runFix(cmd *Command, args []string) bool {
|
||||
fileName := strconv.Itoa(*fixVolumeId)
|
||||
indexFile, err := os.OpenFile(path.Join(*fixVolumePath, fileName+".idx"), os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("Create Volume Index [ERROR] %s\n", err)
|
||||
glog.Fatalf("Create Volume Index [ERROR] %s\n", err)
|
||||
}
|
||||
defer indexFile.Close()
|
||||
|
||||
@@ -57,7 +57,7 @@ func runFix(cmd *Command, args []string) bool {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Export Volume File [ERROR] %s\n", err)
|
||||
glog.Fatalf("Export Volume File [ERROR] %s\n", err)
|
||||
}
|
||||
|
||||
return true
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"code.google.com/p/weed-fs/go/topology"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log"
|
||||
"code.google.com/p/weed-fs/go/glog"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -205,10 +205,10 @@ func runMaster(cmd *Command, args []string) bool {
|
||||
var e error
|
||||
if topo, e = topology.NewTopology("topo", *confFile, *metaFolder, "weed",
|
||||
uint64(*volumeSizeLimitMB)*1024*1024, *mpulse); e != nil {
|
||||
log.Fatalf("cannot create topology:%s", e)
|
||||
glog.Fatalf("cannot create topology:%s", e)
|
||||
}
|
||||
vg = replication.NewDefaultVolumeGrowth()
|
||||
log.Println("Volume Size Limit is", *volumeSizeLimitMB, "MB")
|
||||
glog.V(0).Infoln("Volume Size Limit is", *volumeSizeLimitMB, "MB")
|
||||
http.HandleFunc("/dir/assign", dirAssignHandler)
|
||||
http.HandleFunc("/dir/lookup", dirLookupHandler)
|
||||
http.HandleFunc("/dir/join", dirJoinHandler)
|
||||
@@ -222,7 +222,7 @@ func runMaster(cmd *Command, args []string) bool {
|
||||
|
||||
topo.StartRefreshWritableVolumes(*garbageThreshold)
|
||||
|
||||
log.Println("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport))
|
||||
glog.V(0).Infoln("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport))
|
||||
srv := &http.Server{
|
||||
Addr: ":" + strconv.Itoa(*mport),
|
||||
Handler: http.DefaultServeMux,
|
||||
@@ -230,7 +230,7 @@ func runMaster(cmd *Command, args []string) bool {
|
||||
}
|
||||
e = srv.ListenAndServe()
|
||||
if e != nil {
|
||||
log.Fatalf("Fail to start:%s", e)
|
||||
glog.Fatalf("Fail to start:%s", e)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"code.google.com/p/weed-fs/go/glog"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -28,10 +28,10 @@ func runShell(command *Command, args []string) bool {
|
||||
prompt := func() {
|
||||
var err error
|
||||
if _, err = o.WriteString("> "); err != nil {
|
||||
log.Printf("error writing to stdout: %s", err)
|
||||
glog.V(0).Infoln("error writing to stdout:", err)
|
||||
}
|
||||
if err = o.Flush(); err != nil {
|
||||
log.Printf("error flushing stdout: %s", err)
|
||||
glog.V(0).Infoln("error flushing stdout:", err)
|
||||
}
|
||||
}
|
||||
readLine := func() string {
|
||||
@@ -45,7 +45,7 @@ func runShell(command *Command, args []string) bool {
|
||||
execCmd := func(cmd string) int {
|
||||
if cmd != "" {
|
||||
if _, err := o.WriteString(cmd); err != nil {
|
||||
log.Printf("error writing to stdout: %s", err)
|
||||
glog.V(0).Infoln("error writing to stdout:", err)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
|
@@ -4,7 +4,7 @@ import (
|
||||
"code.google.com/p/weed-fs/go/operation"
|
||||
"code.google.com/p/weed-fs/go/replication"
|
||||
"code.google.com/p/weed-fs/go/storage"
|
||||
"log"
|
||||
"code.google.com/p/weed-fs/go/glog"
|
||||
"math/rand"
|
||||
"mime"
|
||||
"net/http"
|
||||
@@ -145,7 +145,7 @@ func GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool)
|
||||
return
|
||||
}
|
||||
if n.Cookie != cookie {
|
||||
log.Println("request with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent())
|
||||
glog.V(0).Infoln("request with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent())
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if n.Cookie != cookie {
|
||||
log.Println("delete with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent())
|
||||
glog.V(0).Infoln("delete with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ func parseURLPath(path string) (vid, fid, filename, ext string) {
|
||||
commaIndex := strings.LastIndex(path[sepIndex:], ",")
|
||||
if commaIndex <= 0 {
|
||||
if "favicon.ico" != path[sepIndex+1:] {
|
||||
log.Println("unknown file id", path[sepIndex+1:])
|
||||
glog.V(0).Infoln("unknown file id", path[sepIndex+1:])
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -311,23 +311,23 @@ func runVolume(cmd *Command, args []string) bool {
|
||||
if max, e := strconv.Atoi(maxString); e == nil {
|
||||
maxCounts = append(maxCounts, max)
|
||||
} else {
|
||||
log.Fatalf("The max specified in -max not a valid number %s", max)
|
||||
glog.Fatalf("The max specified in -max not a valid number %s", max)
|
||||
}
|
||||
}
|
||||
if len(folders) != len(maxCounts) {
|
||||
log.Fatalf("%d directories by -dir, but only %d max is set by -max", len(folders), len(maxCounts))
|
||||
glog.Fatalf("%d directories by -dir, but only %d max is set by -max", len(folders), len(maxCounts))
|
||||
}
|
||||
for _, folder := range folders {
|
||||
fileInfo, err := os.Stat(folder)
|
||||
if err != nil {
|
||||
log.Fatalf("No Existing Folder:%s", folder)
|
||||
glog.Fatalf("No Existing Folder:%s", folder)
|
||||
}
|
||||
if !fileInfo.IsDir() {
|
||||
log.Fatalf("Volume Folder should not be a file:%s", folder)
|
||||
glog.Fatalf("Volume Folder should not be a file:%s", folder)
|
||||
}
|
||||
perm := fileInfo.Mode().Perm()
|
||||
log.Println("Volume Folder", folder)
|
||||
log.Println("Permission:", perm)
|
||||
glog.V(0).Infoln("Volume Folder", folder)
|
||||
glog.V(0).Infoln("Permission:", perm)
|
||||
}
|
||||
|
||||
if *publicUrl == "" {
|
||||
@@ -355,7 +355,7 @@ func runVolume(cmd *Command, args []string) bool {
|
||||
if err == nil {
|
||||
if !connected {
|
||||
connected = true
|
||||
log.Println("Reconnected with master")
|
||||
glog.V(0).Infoln("Reconnected with master")
|
||||
}
|
||||
} else {
|
||||
if connected {
|
||||
@@ -365,9 +365,9 @@ func runVolume(cmd *Command, args []string) bool {
|
||||
time.Sleep(time.Duration(float32(*vpulse*1e3)*(1+rand.Float32())) * time.Millisecond)
|
||||
}
|
||||
}()
|
||||
log.Println("store joined at", *masterNode)
|
||||
glog.V(0).Infoln("store joined at", *masterNode)
|
||||
|
||||
log.Println("Start Weed volume server", VERSION, "at http://"+*ip+":"+strconv.Itoa(*vport))
|
||||
glog.V(0).Infoln("Start Weed volume server", VERSION, "at http://"+*ip+":"+strconv.Itoa(*vport))
|
||||
srv := &http.Server{
|
||||
Addr: ":" + strconv.Itoa(*vport),
|
||||
Handler: http.DefaultServeMux,
|
||||
@@ -375,7 +375,7 @@ func runVolume(cmd *Command, args []string) bool {
|
||||
}
|
||||
e := srv.ListenAndServe()
|
||||
if e != nil {
|
||||
log.Fatalf("Fail to start:%s", e.Error())
|
||||
glog.Fatalf("Fail to start:%s", e.Error())
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@@ -7,5 +7,5 @@ import (
|
||||
)
|
||||
|
||||
func TestXYZ(t *testing.T) {
|
||||
println("Last-Modified", time.Unix(int64(1373273596), 0).UTC().Format(http.TimeFormat))
|
||||
glog.V(4).Infoln("Last-Modified", time.Unix(int64(1373273596), 0).UTC().Format(http.TimeFormat))
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"code.google.com/p/weed-fs/go/glog"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -42,6 +42,7 @@ func setExitStatus(n int) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
glog.ToStderrAndLog()
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
@@ -207,7 +208,7 @@ func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) (err err
|
||||
// wrapper for writeJson - just logs errors
|
||||
func writeJsonQuiet(w http.ResponseWriter, r *http.Request, obj interface{}) {
|
||||
if err := writeJson(w, r, obj); err != nil {
|
||||
log.Printf("error writing JSON %s: %s", obj, err)
|
||||
glog.V(0).Infof("error writing JSON %s: %s", obj, err.Error())
|
||||
}
|
||||
}
|
||||
func writeJsonError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
@@ -218,6 +219,6 @@ func writeJsonError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
|
||||
func debug(params ...interface{}) {
|
||||
if *IsDebug {
|
||||
log.Println(params)
|
||||
glog.V(0).Infoln(params)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user