mirror of https://github.com/goproxyio/goproxy
replace fmt.Fprintf(os.Stderr, ...) with log.Printf()
parent
6141bae547
commit
55a9e0a0c5
6
main.go
6
main.go
|
@ -83,9 +83,9 @@ func main() {
|
|||
|
||||
var handle http.Handler
|
||||
if proxyHost != "" {
|
||||
fmt.Fprintf(os.Stderr, "ProxyHost %s\n", proxyHost)
|
||||
log.Printf("ProxyHost %s\n", proxyHost)
|
||||
if excludeHost != "" {
|
||||
fmt.Fprintf(os.Stderr, "ExcludeHost %s\n", excludeHost)
|
||||
log.Printf("ExcludeHost %s\n", excludeHost)
|
||||
}
|
||||
handle = &logger{proxy.NewRouter(proxy.NewServer(new(ops)), &proxy.RouterOptions{
|
||||
Pattern: excludeHost,
|
||||
|
@ -129,7 +129,7 @@ func (l *logger) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
start := time.Now()
|
||||
rl := &responseLogger{code: 200, ResponseWriter: w}
|
||||
l.h.ServeHTTP(rl, r)
|
||||
fmt.Fprintf(os.Stderr, "%.3fs %d %s\n", time.Since(start).Seconds(), rl.code, r.URL)
|
||||
log.Printf("%.3fs %d %s\n", time.Since(start).Seconds(), rl.code, r.URL)
|
||||
}
|
||||
|
||||
// An ops is a proxy.ServerOps implementation.
|
||||
|
|
|
@ -2,11 +2,10 @@ package proxy
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
@ -59,11 +58,11 @@ func (rt *Router) Direct(path string) bool {
|
|||
|
||||
func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if rt.proxy != nil && rt.Direct(r.URL.Path) {
|
||||
fmt.Fprintf(os.Stderr, "------ --- %s [direct]\n", r.URL)
|
||||
log.Printf("------ --- %s [direct]\n", r.URL)
|
||||
rt.srv.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "------ --- %s [proxy]\n", r.URL)
|
||||
log.Printf("------ --- %s [proxy]\n", r.URL)
|
||||
rt.proxy.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue