clean log

This commit is contained in:
Chris Lu 2012-08-24 01:14:44 -07:00
parent 869a6711bc
commit 8f9e84bca0
4 changed files with 7 additions and 14 deletions

View file

@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"strings"
@ -42,7 +41,6 @@ func setExitStatus(n int) {
func main() {
flag.Usage = usage
flag.Parse()
log.SetFlags(0)
args := flag.Args()
if len(args) < 1 {
@ -172,8 +170,6 @@ func exit() {
os.Exit(exitStatus)
}
var logf = log.Printf
func exitIfErrors() {
if exitStatus != 0 {
exit()

View file

@ -2,7 +2,6 @@ package directory
import (
"encoding/hex"
"log"
"pkg/storage"
"strings"
"pkg/util"
@ -20,7 +19,7 @@ func NewFileId(VolumeId storage.VolumeId, Key uint64, Hashcode uint32) *FileId {
func ParseFileId(fid string) *FileId{
a := strings.Split(fid, ",")
if len(a) != 2 {
log.Println("Invalid fid", fid, ", split length", len(a))
println("Invalid fid", fid, ", split length", len(a))
return nil
}
vid_string, key_hash_string := a[0], a[1]

View file

@ -5,7 +5,6 @@ import (
"compress/flate"
"compress/gzip"
"io/ioutil"
"log"
"strings"
)
@ -28,10 +27,10 @@ func GzipData(input []byte) []byte {
buf := new(bytes.Buffer)
w, _ := gzip.NewWriterLevel(buf, flate.BestCompression)
if _, err := w.Write(input); err!=nil {
log.Printf("error compressing data:%s\n", err)
println("error compressing data:", err)
}
if err := w.Close(); err!=nil {
log.Printf("error closing compressed data:%s\n", err)
println("error closing compressed data:", err)
}
return buf.Bytes()
}
@ -41,7 +40,7 @@ func UnGzipData(input []byte) []byte {
defer r.Close()
output, err := ioutil.ReadAll(r)
if err!=nil {
log.Printf("error uncompressing data:%s\n", err)
println("error uncompressing data:", err)
}
return output
}

View file

@ -4,7 +4,6 @@ import (
"encoding/hex"
"io"
"io/ioutil"
"log"
"mime"
"net/http"
"os"
@ -27,7 +26,7 @@ func NewNeedle(r *http.Request) (n *Needle, e error) {
n = new(Needle)
form, fe := r.MultipartReader()
if fe != nil {
log.Printf("MultipartReader [ERROR] %s\n", fe)
println("MultipartReader [ERROR]", fe)
e = fe
return
}
@ -60,7 +59,7 @@ func (n *Needle) ParsePath(fid string) {
length := len(fid)
if length <= 8 {
if length > 0 {
log.Println("Invalid fid", fid, "length", length)
println("Invalid fid", fid, "length", length)
}
return
}
@ -118,7 +117,7 @@ func ParseKeyHash(key_hash_string string) (uint64, uint32) {
key_hash_bytes, khe := hex.DecodeString(key_hash_string)
key_hash_len := len(key_hash_bytes)
if khe != nil || key_hash_len <= 4 {
log.Println("Invalid key_hash", key_hash_string, "length:", key_hash_len, "error", khe)
println("Invalid key_hash", key_hash_string, "length:", key_hash_len, "error", khe)
return 0, 0
}
key := util.BytesToUint64(key_hash_bytes[0 : key_hash_len-4])