MCPcopy Create free account
hub / github.com/kataras/iris / LogFailure

Function LogFailure

_examples/database/mongodb/httputil/error.go:85–91  ·  view source on GitHub ↗

LogFailure will print out the failure to the "logger".

(logger io.Writer, ctx iris.Context, err HTTPError)

Source from the content-addressed store, hash-verified

83
84// LogFailure will print out the failure to the "logger".
85func 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`.

Callers 2

InternalServerErrorFunction · 0.85
InternalServerErrorJSONFunction · 0.85

Calls 4

RemoteAddrMethod · 0.80
FullRequestURIMethod · 0.80
FormatMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…