simplify httplog.LogOf

This commit is contained in:
Zhonghu Xu 2018-07-02 11:47:42 +08:00 committed by GitHub
parent 36815869ad
commit 1c5a0218ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,14 +100,11 @@ func NewLogged(req *http.Request, w *http.ResponseWriter) *respLogger {
// then a passthroughLogger will be created which will log to stdout immediately
// when Addf is called.
func LogOf(req *http.Request, w http.ResponseWriter) logger {
if _, exists := w.(*respLogger); !exists {
pl := &passthroughLogger{}
return pl
}
if rl, ok := w.(*respLogger); ok {
return rl
}
panic("Unable to find or create the logger!")
return &passthroughLogger{}
}
// Unlogged returns the original ResponseWriter, or w if it is not our inserted logger.