Skip to content

Commit 2fc7908

Browse files
committed
Attach event identifiers to all the log messages
1 parent 0d9af74 commit 2fc7908

File tree

54 files changed

+365
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+365
-365
lines changed

src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public async ValueTask HandleAsync(TContext context)
260260
// See http://openid.net/specs/openid-connect-core-1_0.html#FormSerialization for more information.
261261
if (string.IsNullOrEmpty(request.ContentType))
262262
{
263-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6138), HeaderNames.ContentType);
263+
context.Logger.LogInformation(6138, SR.GetResourceString(SR.ID6138), HeaderNames.ContentType);
264264

265265
context.Reject(
266266
error: Errors.InvalidRequest,
@@ -273,7 +273,7 @@ public async ValueTask HandleAsync(TContext context)
273273
// May have media/type; charset=utf-8, allow partial match.
274274
if (!request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase))
275275
{
276-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6139), HeaderNames.ContentType, request.ContentType);
276+
context.Logger.LogInformation(6139, SR.GetResourceString(SR.ID6139), HeaderNames.ContentType, request.ContentType);
277277

278278
context.Reject(
279279
error: Errors.InvalidRequest,
@@ -288,7 +288,7 @@ public async ValueTask HandleAsync(TContext context)
288288

289289
else
290290
{
291-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6137), request.Method);
291+
context.Logger.LogInformation(6137, SR.GetResourceString(SR.ID6137), request.Method);
292292

293293
context.Reject(
294294
error: Errors.InvalidRequest,
@@ -1350,7 +1350,7 @@ public async ValueTask HandleAsync(TContext context)
13501350
// Don't return the state originally sent by the client application.
13511351
context.Transaction.Response.State = null;
13521352

1353-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6143), context.Transaction.Response);
1353+
context.Logger.LogInformation(6143, SR.GetResourceString(SR.ID6143), context.Transaction.Response);
13541354

13551355
using var stream = new MemoryStream();
13561356
using var writer = new StreamWriter(stream);
@@ -1409,7 +1409,7 @@ public ValueTask HandleAsync(TContext context)
14091409
throw new ArgumentNullException(nameof(context));
14101410
}
14111411

1412-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6145));
1412+
context.Logger.LogInformation(6145, SR.GetResourceString(SR.ID6145));
14131413
context.HandleRequest();
14141414

14151415
return default;

src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ _ when context.ValidTokenTypes.Contains(TokenTypeIdentifiers.Private.StateToken)
113113

114114
context.Principal = principal;
115115

116-
context.Logger.LogTrace(SR.GetResourceString(SR.ID6152), context.Token, context.Principal.Claims);
116+
context.Logger.LogTrace(6152, SR.GetResourceString(SR.ID6152), context.Token, context.Principal.Claims);
117117

118118
return default;
119119

@@ -145,7 +145,7 @@ _ when context.ValidTokenTypes.Contains(TokenTypeIdentifiers.Private.StateToken)
145145

146146
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
147147
{
148-
context.Logger.LogTrace(exception, SR.GetResourceString(SR.ID6153), context.Token);
148+
context.Logger.LogTrace(6153, exception, SR.GetResourceString(SR.ID6153), context.Token);
149149

150150
return null;
151151
}
@@ -256,7 +256,7 @@ public ValueTask HandleAsync(GenerateTokenContext context)
256256

257257
context.Token = Base64UrlEncoder.Encode(protector.Protect(buffer.ToArray()));
258258

259-
context.Logger.LogTrace(SR.GetResourceString(SR.ID6016), context.TokenType,
259+
context.Logger.LogTrace(6016, SR.GetResourceString(SR.ID6016), context.TokenType,
260260
context.Token, context.Principal.Claims);
261261

262262
return default;

src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ from parameter in request.Query
266266
// See http://openid.net/specs/openid-connect-core-1_0.html#FormSerialization for more information.
267267
if (string.IsNullOrEmpty(request.ContentType))
268268
{
269-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6138), Headers.ContentType);
269+
context.Logger.LogInformation(6138, SR.GetResourceString(SR.ID6138), Headers.ContentType);
270270

271271
context.Reject(
272272
error: Errors.InvalidRequest,
@@ -279,7 +279,7 @@ from parameter in request.Query
279279
// May have media/type; charset=utf-8, allow partial match.
280280
if (!request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase))
281281
{
282-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6139), Headers.ContentType, request.ContentType);
282+
context.Logger.LogInformation(6139, SR.GetResourceString(SR.ID6139), Headers.ContentType, request.ContentType);
283283

284284
context.Reject(
285285
error: Errors.InvalidRequest,
@@ -297,7 +297,7 @@ from parameter in await request.ReadFormAsync()
297297

298298
else
299299
{
300-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6137), request.Method);
300+
context.Logger.LogInformation(6137, SR.GetResourceString(SR.ID6137), request.Method);
301301

302302
context.Reject(
303303
error: Errors.InvalidRequest,
@@ -1473,7 +1473,7 @@ public async ValueTask HandleAsync(TContext context)
14731473
// Don't return the state originally sent by the client application.
14741474
context.Transaction.Response.State = null;
14751475

1476-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6143), context.Transaction.Response);
1476+
context.Logger.LogInformation(6143, SR.GetResourceString(SR.ID6143), context.Transaction.Response);
14771477

14781478
using var stream = new MemoryStream();
14791479
using var writer = new StreamWriter(stream);
@@ -1532,7 +1532,7 @@ public ValueTask HandleAsync(TContext context)
15321532
throw new ArgumentNullException(nameof(context));
15331533
}
15341534

1535-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6145));
1535+
context.Logger.LogInformation(6145, SR.GetResourceString(SR.ID6145));
15361536
context.HandleRequest();
15371537

15381538
return default;

src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public async ValueTask HandleAsync(ApplyAuthorizationRequestContext context)
182182

183183
catch (NSErrorException exception)
184184
{
185-
context.Logger.LogError(exception, SR.GetResourceString(SR.ID6231));
185+
context.Logger.LogError(6231, exception, SR.GetResourceString(SR.ID6231));
186186

187187
context.Reject(
188188
error: Errors.ServerError,

src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public async ValueTask HandleAsync(ApplyEndSessionRequestContext context)
182182

183183
catch (NSErrorException exception)
184184
{
185-
context.Logger.LogError(exception, SR.GetResourceString(SR.ID6232));
185+
context.Logger.LogError(6232, exception, SR.GetResourceString(SR.ID6232));
186186

187187
context.Reject(
188188
error: Errors.ServerError,

src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public ValueTask HandleAsync(TContext context)
391391
// If the incoming request doesn't use GET, reject it.
392392
if (!string.Equals(request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
393393
{
394-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6137), request.HttpMethod);
394+
context.Logger.LogInformation(6137, SR.GetResourceString(SR.ID6137), request.HttpMethod);
395395

396396
context.Reject(
397397
error: Errors.InvalidRequest,
@@ -456,7 +456,7 @@ public async ValueTask HandleAsync(TContext context)
456456
if (!MediaTypeHeaderValue.TryParse(request.ContentType, out MediaTypeHeaderValue? type) ||
457457
StringSegment.IsNullOrEmpty(type.MediaType))
458458
{
459-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6138), "Content-Type");
459+
context.Logger.LogInformation(6138, SR.GetResourceString(SR.ID6138), "Content-Type");
460460

461461
context.Reject(
462462
error: Errors.InvalidRequest,
@@ -468,7 +468,7 @@ public async ValueTask HandleAsync(TContext context)
468468

469469
if (!StringSegment.Equals(type.MediaType, "application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase))
470470
{
471-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6139), "Content-Type", request.ContentType);
471+
context.Logger.LogInformation(6139, SR.GetResourceString(SR.ID6139), "Content-Type", request.ContentType);
472472

473473
context.Reject(
474474
error: Errors.InvalidRequest,
@@ -488,7 +488,7 @@ public async ValueTask HandleAsync(TContext context)
488488

489489
else
490490
{
491-
context.Logger.LogInformation(SR.GetResourceString(SR.ID6137), request.HttpMethod);
491+
context.Logger.LogInformation(6137, SR.GetResourceString(SR.ID6137), request.HttpMethod);
492492

493493
context.Reject(
494494
error: Errors.InvalidRequest,
@@ -966,7 +966,7 @@ public async ValueTask HandleAsync(ProcessAuthenticationContext context)
966966

967967
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
968968
{
969-
context.Logger.LogWarning(SR.GetResourceString(SR.ID6215), identifier);
969+
context.Logger.LogWarning(6215, SR.GetResourceString(SR.ID6215), identifier);
970970
}
971971

972972
// Inform the host that the application should stop and mark the authentication context as handled

src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static async Task ProcessRequestsAsync(HttpListener listener, OpenIddictClientSy
249249
// Swallow other exceptions to ensure the worker doesn't exit when encountering an exception.
250250
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
251251
{
252-
logger.LogWarning(exception, SR.GetResourceString(SR.ID6214));
252+
logger.LogWarning(6214, exception, SR.GetResourceString(SR.ID6214));
253253

254254
continue;
255255
}

src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationPipeListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ 0x01 when ReadProtocolActivation(reader) is var activation
122122
// Swallow other exceptions to ensure the service doesn't exit when encountering an exception.
123123
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
124124
{
125-
logger.LogWarning(exception, SR.GetResourceString(SR.ID6213));
125+
logger.LogWarning(6213, exception, SR.GetResourceString(SR.ID6213));
126126

127127
continue;
128128
}

src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ public async ValueTask HandleAsync(TContext context)
11111111
// In this case, log the error details and return a generic error to stop processing the event.
11121112
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
11131113
{
1114-
context.Logger.LogError(exception, SR.GetResourceString(SR.ID6182));
1114+
context.Logger.LogError(6182, exception, SR.GetResourceString(SR.ID6182));
11151115

11161116
context.Reject(
11171117
error: Errors.ServerError,
@@ -1368,7 +1368,7 @@ public async ValueTask HandleAsync(TContext context)
13681368
// a server error occurs while the JSON response is being generated and returned to the client.
13691369
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception))
13701370
{
1371-
context.Logger.LogError(exception, SR.GetResourceString(SR.ID6183),
1371+
context.Logger.LogError(6183, exception, SR.GetResourceString(SR.ID6183),
13721372
await response.Content.ReadAsStringAsync());
13731373

13741374
context.Reject(
@@ -1552,7 +1552,7 @@ public async ValueTask HandleAsync(TContext context)
15521552
// error could be extracted from the payload or from the WWW-Authenticate header.
15531553
if (!response.IsSuccessStatusCode && string.IsNullOrEmpty(context.Transaction.Response?.Error))
15541554
{
1555-
context.Logger.LogError(SR.GetResourceString(SR.ID6184), response.StatusCode,
1555+
context.Logger.LogError(6184, SR.GetResourceString(SR.ID6184), response.StatusCode,
15561556
await response.Content.ReadAsStringAsync());
15571557

15581558
context.Reject(
@@ -1576,7 +1576,7 @@ public async ValueTask HandleAsync(TContext context)
15761576
// (e.g because an unsupported content type was returned), return a generic error.
15771577
if (context.Transaction.Response is null)
15781578
{
1579-
context.Logger.LogError(SR.GetResourceString(SR.ID6185), response.StatusCode,
1579+
context.Logger.LogError(6185, SR.GetResourceString(SR.ID6185), response.StatusCode,
15801580
response.Content.Headers.ContentType, await response.Content.ReadAsStringAsync());
15811581

15821582
context.Reject(

src/OpenIddict.Client/OpenIddictClientDispatcher.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,36 @@ public async ValueTask DispatchAsync<TContext>(TContext context) where TContext
5151

5252
catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception) && _logger.IsEnabled(LogLevel.Debug))
5353
{
54-
_logger.LogDebug(exception, SR.GetResourceString(SR.ID6132), handler.GetType().FullName, typeof(TContext).FullName);
54+
_logger.LogDebug(6132, exception, SR.GetResourceString(SR.ID6132), handler.GetType().FullName, typeof(TContext).FullName);
5555

5656
throw;
5757
}
5858

5959
if (_logger.IsEnabled(LogLevel.Debug))
6060
{
61-
_logger.LogDebug(SR.GetResourceString(SR.ID6133), typeof(TContext).FullName, handler.GetType().FullName);
61+
_logger.LogDebug(6133, SR.GetResourceString(SR.ID6133), typeof(TContext).FullName, handler.GetType().FullName);
6262
}
6363

6464
switch (context)
6565
{
6666
case BaseRequestContext { IsRequestHandled: true }:
6767
if (_logger.IsEnabled(LogLevel.Debug))
6868
{
69-
_logger.LogDebug(SR.GetResourceString(SR.ID6134), typeof(TContext).FullName, handler.GetType().FullName);
69+
_logger.LogDebug(6134, SR.GetResourceString(SR.ID6134), typeof(TContext).FullName, handler.GetType().FullName);
7070
}
7171
return;
7272

7373
case BaseRequestContext { IsRequestSkipped: true }:
7474
if (_logger.IsEnabled(LogLevel.Debug))
7575
{
76-
_logger.LogDebug(SR.GetResourceString(SR.ID6135), typeof(TContext).FullName, handler.GetType().FullName);
76+
_logger.LogDebug(6135, SR.GetResourceString(SR.ID6135), typeof(TContext).FullName, handler.GetType().FullName);
7777
}
7878
return;
7979

8080
case BaseValidatingContext { IsRejected: true }:
8181
if (_logger.IsEnabled(LogLevel.Debug))
8282
{
83-
_logger.LogDebug(SR.GetResourceString(SR.ID6136), typeof(TContext).FullName, handler.GetType().FullName);
83+
_logger.LogDebug(6136, SR.GetResourceString(SR.ID6136), typeof(TContext).FullName, handler.GetType().FullName);
8484
}
8585
return;
8686

0 commit comments

Comments
 (0)