1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-22 04:17:03 +00:00

request logger middleware: add graphical information about executed route's handlers

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-19 01:24:36 +03:00
parent 4228dd8ea4
commit bdb94bbae2
6 changed files with 74 additions and 31 deletions

View File

@@ -388,7 +388,7 @@ func traceMethodColor(method string) int {
// * @handler_name (@handler_rel_location)
// * @second_handler ...
// If route and handler line:number locations are equal then the second is ignored.
func (r *Route) Trace(w io.Writer) {
func (r *Route) Trace(w io.Writer, stoppedIndex int) {
method := r.Method
if method == "" {
method = fmt.Sprintf("%d", r.StatusCode)
@@ -470,6 +470,13 @@ func (r *Route) Trace(w io.Writer) {
// * @handler_name (@handler_rel_location)
fmt.Fprint(w, traceHandlerFile(r.Method, name, file, line))
if stoppedIndex != -1 && stoppedIndex <= len(r.Handlers) {
if i <= stoppedIndex {
pio.WriteRich(w, " ✓", pio.Green)
} else {
// pio.WriteRich(w, " ✕", pio.Red, pio.Underline)
}
}
}
fmt.Fprintln(w)
@@ -499,8 +506,8 @@ func (rd routeReadOnlyWrapper) Path() string {
return rd.Route.tmpl.Src
}
func (rd routeReadOnlyWrapper) Trace(w io.Writer) {
rd.Route.Trace(w)
func (rd routeReadOnlyWrapper) Trace(w io.Writer, stoppedIndex int) {
rd.Route.Trace(w, stoppedIndex)
}
func (rd routeReadOnlyWrapper) Tmpl() macro.Template {