back to http request logging handler

gnutls_nghttp2
fangdingjun 6 years ago
parent a139774bdb
commit 3bb90d264f

@ -16,6 +16,7 @@ import (
"github.com/fangdingjun/gnutls"
auth "github.com/fangdingjun/go-http-auth"
"github.com/fangdingjun/gofast"
loghandler "github.com/gorilla/handlers"
"github.com/gorilla/mux"
)
@ -32,8 +33,7 @@ func (lw *logwriter) Write(buf []byte) (int, error) {
func initRouters(cfg conf) {
//logout := os.Stdout
/*
logout := os.Stdout
if logfile != "" {
fp, err := os.OpenFile(logfile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
@ -42,9 +42,8 @@ func initRouters(cfg conf) {
logout = fp
}
}
*/
//w := &logwriter{logout, new(sync.Mutex)}
w := &logwriter{logout, new(sync.Mutex)}
for _, l := range cfg {
router := mux.NewRouter()
@ -137,8 +136,8 @@ func initRouters(cfg conf) {
log.Fatal(err)
}
//handler := loghandler.CombinedLoggingHandler(w, hdlr)
handler := hdlr
handler := loghandler.CombinedLoggingHandler(w, hdlr)
//handler := hdlr
log.Printf("listen https on %s", addr)
go func() {
defer listener.Close()
@ -154,8 +153,8 @@ func initRouters(cfg conf) {
} else {
log.Printf("listen http on %s", addr)
//handler := loghandler.CombinedLoggingHandler(w, hdlr),
handler := hdlr
handler := loghandler.CombinedLoggingHandler(w, hdlr)
//handler := hdlr
if err := http.ListenAndServe(
addr, handler,
); err != nil {

Loading…
Cancel
Save