From be9421fedf9017f1ea48c292a2ba7c9d8e3ed9dc Mon Sep 17 00:00:00 2001 From: eMeab <32988354+eMeab@users.noreply.github.com> Date: Mon, 4 Jan 2021 13:05:38 +0800 Subject: [PATCH] Optimized log (#121) --- app/dispatcher/default.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 03efd2d2..ea5c8fa1 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -263,9 +263,11 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport. skipRoutePick = content.SkipRoutePick } + var inTag string if d.router != nil && !skipRoutePick { if route, err := d.router.PickRoute(routing_session.AsRoutingContext(ctx)); err == nil { tag := route.GetOutboundTag() + inTag = route.GetInboundTag() if h := d.ohm.GetHandler(tag); h != nil { newError("taking detour [", tag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx)) handler = h @@ -290,7 +292,11 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport. if accessMessage := log.AccessMessageFromContext(ctx); accessMessage != nil { if tag := handler.Tag(); tag != "" { - accessMessage.Detour = tag + if inTag != "" { + accessMessage.Detour = inTag + " -> " + tag + } else { + accessMessage.Detour = tag + } } log.Record(accessMessage) }