Skip to content

Commit bcfc1b4

Browse files
committed
Logging
1 parent 5027d6a commit bcfc1b4

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/Servers/Kestrel/Transport.Quic/src/Internal/IQuicTrace.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ internal interface IQuicTrace : ILogger
2121
void StreamShutdownWrite(QuicStreamContext streamContext, string reason);
2222
void StreamAborted(QuicStreamContext streamContext, Exception ex);
2323
void StreamAbort(QuicStreamContext streamContext, string reason);
24+
void StreamAbortRead(QuicStreamContext streamContext, string reason);
25+
void StreamAbortWrite(QuicStreamContext streamContext, string reason);
2426
}
2527
}

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ public void AbortRead(ConnectionAbortedException abortReason)
318318
{
319319
if (_stream.CanRead)
320320
{
321+
_log.StreamAbortRead(this, abortReason.Message);
321322
_stream.AbortRead(Error);
322323
}
323324
else
@@ -333,6 +334,7 @@ public void AbortWrite(ConnectionAbortedException abortReason)
333334
{
334335
if (_stream.CanWrite)
335336
{
337+
_log.StreamAbortWrite(this, abortReason.Message);
336338
_stream.AbortWrite(Error);
337339
}
338340
else

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicTrace.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ internal class QuicTrace : IQuicTrace
3535
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(11, "StreamAborted"), @"Stream id ""{ConnectionId}"" aborted by peer.", SkipEnabledCheckLogOptions);
3636
private static readonly Action<ILogger, string, string, Exception?> _streamAbort =
3737
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(12, "StreamAbort"), @"Stream id ""{ConnectionId}"" aborted by application because: ""{Reason}"".", SkipEnabledCheckLogOptions);
38+
private static readonly Action<ILogger, string, string, Exception?> _streamAbortRead =
39+
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(13, "StreamAbortRead"), @"Stream id ""{ConnectionId}"" read side aborted by application because: ""{Reason}"".", SkipEnabledCheckLogOptions);
40+
private static readonly Action<ILogger, string, string, Exception?> _streamAbortWrite =
41+
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(14, "StreamAbortWrite"), @"Stream id ""{ConnectionId}"" write side aborted by application because: ""{Reason}"".", SkipEnabledCheckLogOptions);
3842

3943
private readonly ILogger _logger;
4044

@@ -146,6 +150,22 @@ public void StreamAbort(QuicStreamContext streamContext, string reason)
146150
}
147151
}
148152

153+
public void StreamAbortRead(QuicStreamContext streamContext, string reason)
154+
{
155+
if (_logger.IsEnabled(LogLevel.Debug))
156+
{
157+
_streamAbortRead(_logger, streamContext.ConnectionId, reason, null);
158+
}
159+
}
160+
161+
public void StreamAbortWrite(QuicStreamContext streamContext, string reason)
162+
{
163+
if (_logger.IsEnabled(LogLevel.Debug))
164+
{
165+
_streamAbortWrite(_logger, streamContext.ConnectionId, reason, null);
166+
}
167+
}
168+
149169
private StreamType GetStreamType(QuicStreamContext streamContext) =>
150170
streamContext.CanRead && streamContext.CanWrite
151171
? StreamType.Bidirectional

0 commit comments

Comments
 (0)