Skip to content

Commit 37f8a37

Browse files
authored
add type assertion to logger (#43)
1 parent a36a79c commit 37f8a37

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

protocol/group/mutableurltest.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ func NewMutableURLTest(ctx context.Context, _ A.Router, logger log.ContextLogger
6868
options.Tolerance = 50
6969
}
7070

71-
log := sbxL.NewFactory(logger.(sbxL.SLogger).SlogHandler().WithAttrs([]slog.Attr{slog.String("urltest_group", tag)}))
71+
log := logger
72+
if slogger, ok := logger.(sbxL.SLogger); ok {
73+
nfact := sbxL.NewFactory(slogger.SlogHandler().WithAttrs([]slog.Attr{slog.String("urltest_group", tag)}))
74+
log = nfact.Logger()
75+
}
7276
outboundMgr := service.FromContext[A.OutboundManager](ctx)
7377
outbound := &MutableURLTest{
7478
Adapter: outbound.NewAdapter(constant.TypeMutableURLTest, tag, []string{"tcp", "udp"}, nil),
@@ -77,7 +81,7 @@ func NewMutableURLTest(ctx context.Context, _ A.Router, logger log.ContextLogger
7781
connMgr: service.FromContext[A.ConnectionManager](ctx),
7882
logger: logger,
7983
group: newURLTestGroup(
80-
ctx, outboundMgr, log.Logger(), options.Outbounds, options.URL, interval, idleTimeout, options.Tolerance,
84+
ctx, outboundMgr, log, options.Outbounds, options.URL, interval, idleTimeout, options.Tolerance,
8185
),
8286
}
8387
return outbound, nil

0 commit comments

Comments
 (0)