1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 11:57:02 +00:00

logging: several improvements

Former-commit-id: 12538c74a1aa55314c35ac3cf2665646b704851d
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-04-28 01:58:56 +03:00
parent b02706f207
commit 27ca1c93f5
11 changed files with 125 additions and 56 deletions

View File

@@ -11,6 +11,7 @@ import (
macroHandler "github.com/kataras/iris/v12/macro/handler"
"github.com/kataras/golog"
"github.com/kataras/pio"
)
// RequestHandler the middle man between acquiring a context and releasing it.
@@ -156,6 +157,13 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
}
if golog.Default.Level == golog.DebugLevel {
tr := "routes"
if len(registeredRoutes) == 1 {
tr = tr[0 : len(tr)-1]
}
golog.Debugf("API: [%d] %s", len(registeredRoutes), tr)
// group routes by method and print them without the [DBUG] and time info,
// the route logs are colorful.
// Note: don't use map, we need to keep registered order, use
@@ -176,9 +184,15 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
for _, method := range append(AllMethods, MethodNone) {
methodRoutes := collect(method)
for _, r := range methodRoutes {
golog.Println(r.Trace())
if len(methodRoutes) == 0 {
continue
}
for _, r := range methodRoutes {
r.Trace(golog.Default.Printer)
}
golog.Default.Printer.Write(pio.NewLine)
}
}