Audit use of log.Print and change to Debug, Log, or ErrorLog as appropriate
This commit is contained in:
+1
-2
@@ -6,7 +6,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -147,7 +146,7 @@ Elapsed time: %10v
|
||||
|
||||
// Log outputs the StatsInfo to the log
|
||||
func (s *StatsInfo) Log() {
|
||||
log.Printf("%v\n", s)
|
||||
Log(nil, "%v\n", s)
|
||||
}
|
||||
|
||||
// Bytes updates the stats for bytes bytes
|
||||
|
||||
+9
-9
@@ -292,10 +292,10 @@ func configHome() string {
|
||||
if home != "" {
|
||||
return home
|
||||
}
|
||||
log.Printf("Couldn't find home directory or read HOME environment variable.")
|
||||
log.Printf("Defaulting to storing config in current directory.")
|
||||
log.Printf("Use -config flag to workaround.")
|
||||
log.Printf("Error was: %v", err)
|
||||
ErrorLog(nil, "Couldn't find home directory or read HOME environment variable.")
|
||||
ErrorLog(nil, "Defaulting to storing config in current directory.")
|
||||
ErrorLog(nil, "Use -config flag to workaround.")
|
||||
ErrorLog(nil, "Error was: %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ func LoadConfig() {
|
||||
func loadConfigFile() (*goconfig.ConfigFile, error) {
|
||||
b, err := ioutil.ReadFile(ConfigPath)
|
||||
if err != nil {
|
||||
log.Printf("Failed to load config file \"%v\" - using defaults: %v", ConfigPath, err)
|
||||
Log(nil, "Failed to load config file \"%v\" - using defaults: %v", ConfigPath, err)
|
||||
return goconfig.LoadFromReader(&bytes.Buffer{})
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ func loadConfigFile() (*goconfig.ConfigFile, error) {
|
||||
}
|
||||
|
||||
// Retry
|
||||
log.Println("Couldn't decrypt configuration, most likely wrong password.")
|
||||
ErrorLog(nil, "Couldn't decrypt configuration, most likely wrong password.")
|
||||
configKey = nil
|
||||
envpw = ""
|
||||
}
|
||||
@@ -509,7 +509,7 @@ func SaveConfig() {
|
||||
}
|
||||
err = os.Chmod(ConfigPath, 0600)
|
||||
if err != nil {
|
||||
log.Printf("Failed to set permissions on config file: %v", err)
|
||||
ErrorLog(nil, "Failed to set permissions on config file: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -556,7 +556,7 @@ func SaveConfig() {
|
||||
|
||||
err = os.Chmod(ConfigPath, 0600)
|
||||
if err != nil {
|
||||
log.Printf("Failed to set permissions on config file: %v", err)
|
||||
ErrorLog(nil, "Failed to set permissions on config file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ func OkRemote(name string) bool {
|
||||
ConfigFile.DeleteSection(name)
|
||||
return true
|
||||
default:
|
||||
log.Printf("Bad choice %d", i)
|
||||
ErrorLog(nil, "Bad choice %d", i)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+10
-11
@@ -3,7 +3,6 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
)
|
||||
@@ -35,7 +34,7 @@ func (t *LoggedTransport) CancelRequest(req *http.Request) {
|
||||
if wrapped, ok := t.wrapped.(interface {
|
||||
CancelRequest(*http.Request)
|
||||
}); ok {
|
||||
log.Printf("CANCEL REQUEST %v", req)
|
||||
Debug(nil, "CANCEL REQUEST %v", req)
|
||||
wrapped.CancelRequest(req)
|
||||
}
|
||||
}
|
||||
@@ -43,19 +42,19 @@ func (t *LoggedTransport) CancelRequest(req *http.Request) {
|
||||
// RoundTrip implements the RoundTripper interface.
|
||||
func (t *LoggedTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
|
||||
buf, _ := httputil.DumpRequestOut(req, t.logBody)
|
||||
log.Println(separatorReq)
|
||||
log.Println("HTTP REQUEST")
|
||||
log.Println(string(buf))
|
||||
log.Println(separatorReq)
|
||||
Debug(nil, "%s", separatorReq)
|
||||
Debug(nil, "%s", "HTTP REQUEST")
|
||||
Debug(nil, "%s", string(buf))
|
||||
Debug(nil, "%s", separatorReq)
|
||||
resp, err = t.wrapped.RoundTrip(req)
|
||||
log.Println(separatorResp)
|
||||
log.Println("HTTP RESPONSE")
|
||||
Debug(nil, "%s", separatorResp)
|
||||
Debug(nil, "%s", "HTTP RESPONSE")
|
||||
if err != nil {
|
||||
log.Printf("Error: %v\n", err)
|
||||
Debug(nil, "Error: %v", err)
|
||||
} else {
|
||||
buf, _ = httputil.DumpResponse(resp, t.logBody)
|
||||
log.Println(string(buf))
|
||||
Debug(nil, "%s", string(buf))
|
||||
}
|
||||
log.Println(separatorResp)
|
||||
Debug(nil, "%s", separatorResp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user