Browse Source

api: log requests even with logLevel: info

pull/666/head
aler9 5 years ago
parent
commit
e6238694af
  1. 6
      internal/core/api.go
  2. 6
      internal/core/hls_server.go

6
internal/core/api.go

@ -334,8 +334,10 @@ func (a *api) log(level logger.Level, format string, args ...interface{}) {
} }
func (a *api) mwLog(ctx *gin.Context) { func (a *api) mwLog(ctx *gin.Context) {
a.log(logger.Info, "[conn %v] %s %s", ctx.Request.RemoteAddr, ctx.Request.Method, ctx.Request.URL.Path)
byts, _ := httputil.DumpRequest(ctx.Request, true) byts, _ := httputil.DumpRequest(ctx.Request, true)
a.log(logger.Debug, "[c->s] %s", string(byts)) a.log(logger.Debug, "[conn %v] [c->s] %s", ctx.Request.RemoteAddr, string(byts))
logw := &httpLogWriter{ResponseWriter: ctx.Writer} logw := &httpLogWriter{ResponseWriter: ctx.Writer}
ctx.Writer = logw ctx.Writer = logw
@ -344,7 +346,7 @@ func (a *api) mwLog(ctx *gin.Context) {
ctx.Next() ctx.Next()
a.log(logger.Debug, "[s->c] %s", logw.dump()) a.log(logger.Debug, "[conn %v] [s->c] %s", ctx.Request.RemoteAddr, logw.dump())
} }
func (a *api) onConfigGet(ctx *gin.Context) { func (a *api) onConfigGet(ctx *gin.Context) {

6
internal/core/hls_server.go

@ -138,10 +138,10 @@ outer:
} }
func (s *hlsServer) onRequest(ctx *gin.Context) { func (s *hlsServer) onRequest(ctx *gin.Context) {
s.Log(logger.Info, "[client %v] %s %s", ctx.Request.RemoteAddr, ctx.Request.Method, ctx.Request.URL.Path) s.Log(logger.Info, "[conn %v] %s %s", ctx.Request.RemoteAddr, ctx.Request.Method, ctx.Request.URL.Path)
byts, _ := httputil.DumpRequest(ctx.Request, true) byts, _ := httputil.DumpRequest(ctx.Request, true)
s.Log(logger.Debug, "[client %v] [c->s] %s", ctx.Request.RemoteAddr, string(byts)) s.Log(logger.Debug, "[conn %v] [c->s] %s", ctx.Request.RemoteAddr, string(byts))
logw := &httpLogWriter{ResponseWriter: ctx.Writer} logw := &httpLogWriter{ResponseWriter: ctx.Writer}
ctx.Writer = logw ctx.Writer = logw
@ -212,7 +212,7 @@ func (s *hlsServer) onRequest(ctx *gin.Context) {
case <-s.ctx.Done(): case <-s.ctx.Done():
} }
s.Log(logger.Debug, "[client %v] [s->c] %s", ctx.Request.RemoteAddr, logw.dump()) s.Log(logger.Debug, "[conn %v] [s->c] %s", ctx.Request.RemoteAddr, logw.dump())
} }
func (s *hlsServer) findOrCreateMuxer(pathName string) *hlsMuxer { func (s *hlsServer) findOrCreateMuxer(pathName string) *hlsMuxer {

Loading…
Cancel
Save