LogFailure will print out the failure to the "logger".
(logger io.Writer, ctx iris.Context, err HTTPError)
| 83 | |
| 84 | // LogFailure will print out the failure to the "logger". |
| 85 | func LogFailure(logger io.Writer, ctx iris.Context, err HTTPError) { |
| 86 | timeFmt := err.When.Format("2006/01/02 15:04:05") |
| 87 | firstLine := fmt.Sprintf("%s %s: %s", timeFmt, http.StatusText(err.StatusCode), err.Error()) |
| 88 | whitespace := strings.Repeat(" ", len(timeFmt)+1) |
| 89 | fmt.Fprintf(logger, "%s\n%sIP: %s\n%sURL: %s\n%sSource: %s\n", |
| 90 | firstLine, whitespace, ctx.RemoteAddr(), whitespace, ctx.FullRequestURI(), whitespace, err.CallerStack) |
| 91 | } |
| 92 | |
| 93 | // Fail will send the status code, write the error's reason |
| 94 | // and return the HTTPError for further use, i.e logging, see `InternalServerError`. |
no test coverage detected
searching dependent graphs…