Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Улучшен лог при ошибках
Browse files Browse the repository at this point in the history
  • Loading branch information
xtrafrancyz committed Aug 21, 2018
1 parent 7c97f4c commit 1113635
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ func (p *Proxy) handleProxy(ctx *fasthttp.RequestCtx) {
err = p.processProxyResponse(baseDomain, ctx)
}

elapsed := time.Since(start).Round(100 * time.Microsecond)

if err != nil {
ctx.Logger().Printf("error when proxying the request: %s", err)
log.Printf("%s %s error: %s", elapsed, ctx.Path(), err)
if strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "timeout") {
ctx.Error("408 Request Timeout", 408)
} else {
Expand All @@ -143,7 +145,6 @@ func (p *Proxy) handleProxy(ctx *fasthttp.RequestCtx) {
p.tracker.trackRequest(string(ip), len(ctx.Response.Body()))
}

elapsed := time.Since(start).Round(100 * time.Microsecond)
if p.config.LogVerbosity == 2 {
log.Printf("%s %s %s", elapsed, ctx.Path(), bytefmt.ByteSize(uint64(len(ctx.Response.Body()))))
} else if p.config.LogVerbosity == 3 {
Expand Down

0 comments on commit 1113635

Please sign in to comment.