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
|
var handle http.Handler
|
||||||
if proxyHost != "" {
|
if proxyHost != "" {
|
||||||
fmt.Fprintf(os.Stderr, "ProxyHost %s\n", proxyHost)
|
log.Printf("ProxyHost %s\n", proxyHost)
|
||||||
if excludeHost != "" {
|
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{
|
handle = &logger{proxy.NewRouter(proxy.NewServer(new(ops)), &proxy.RouterOptions{
|
||||||
Pattern: excludeHost,
|
Pattern: excludeHost,
|
||||||
|
@ -129,7 +129,7 @@ func (l *logger) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
rl := &responseLogger{code: 200, ResponseWriter: w}
|
rl := &responseLogger{code: 200, ResponseWriter: w}
|
||||||
l.h.ServeHTTP(rl, r)
|
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.
|
// An ops is a proxy.ServerOps implementation.
|
||||||
|
|
|
@ -2,11 +2,10 @@ package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -59,11 +58,11 @@ func (rt *Router) Direct(path string) bool {
|
||||||
|
|
||||||
func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if rt.proxy != nil && rt.Direct(r.URL.Path) {
|
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)
|
rt.srv.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintf(os.Stderr, "------ --- %s [proxy]\n", r.URL)
|
log.Printf("------ --- %s [proxy]\n", r.URL)
|
||||||
rt.proxy.ServeHTTP(w, r)
|
rt.proxy.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue