Refactor logging into separate package
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package upnp
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/calmh/syncthing/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
dlog = log.New(os.Stderr, "upnp: ", log.Lmicroseconds|log.Lshortfile)
|
||||
debug = strings.Contains(os.Getenv("STTRACE"), "upnp")
|
||||
debug = strings.Contains(os.Getenv("STTRACE"), "upnp") || os.Getenv("STTRACE") == "all"
|
||||
l = logger.DefaultLogger
|
||||
)
|
||||
|
||||
@@ -81,7 +81,7 @@ Mx: 3
|
||||
}
|
||||
|
||||
if debug {
|
||||
dlog.Println(string(resp[:n]))
|
||||
l.Debugln(string(resp[:n]))
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(bytes.NewBuffer(resp[:n]))
|
||||
@@ -225,8 +225,8 @@ func soapRequest(url, function, message string) error {
|
||||
req.Header.Set("Pragma", "no-cache")
|
||||
|
||||
if debug {
|
||||
dlog.Println(req.Header.Get("SOAPAction"))
|
||||
dlog.Println(body)
|
||||
l.Debugln(req.Header.Get("SOAPAction"))
|
||||
l.Debugln(body)
|
||||
}
|
||||
|
||||
r, err := http.DefaultClient.Do(req)
|
||||
@@ -236,7 +236,7 @@ func soapRequest(url, function, message string) error {
|
||||
|
||||
if debug {
|
||||
resp, _ := ioutil.ReadAll(r.Body)
|
||||
dlog.Println(string(resp))
|
||||
l.Debugln(string(resp))
|
||||
}
|
||||
|
||||
r.Body.Close()
|
||||
|
||||
Reference in New Issue
Block a user