Skip to content

Commit ae4e200

Browse files
committed
Remove two logging options: LogEndpointCreatedInfo and LogAnnotationSetInfo. By default, all command parameters and values are logged at Debug level.
1 parent 075fe11 commit ae4e200

6 files changed

Lines changed: 47 additions & 165 deletions

File tree

NpgsqlRest/Defaults/DefaultCommentParser.cs

Lines changed: 42 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,7 @@ internal static class DefaultCommentParser
286286
routineEndpoint.CustomParamsNeedParsing = true;
287287
}
288288
SetCustomParameter(routineEndpoint, customParamName, customParamValue);
289-
if (Options.LogAnnotationSetInfo)
290-
{
291-
Logger?.CommentSetCustomParemeter(description, customParamName, customParamValue);
292-
}
289+
Logger?.CommentSetCustomParemeter(description, customParamName, customParamValue);
293290
}
294291

295292
// key: value
@@ -304,10 +301,7 @@ internal static class DefaultCommentParser
304301
{
305302
if (!string.Equals(routineEndpoint.ResponseContentType, headerValue))
306303
{
307-
if (Options.LogAnnotationSetInfo)
308-
{
309-
Logger?.CommentSetContentType(description, headerValue);
310-
}
304+
Logger?.CommentSetContentType(description, headerValue);
311305
}
312306
routineEndpoint.ResponseContentType = headerValue;
313307
}
@@ -333,10 +327,7 @@ internal static class DefaultCommentParser
333327
}
334328
if (!string.Equals(routineEndpoint.ResponseContentType, headerValue))
335329
{
336-
if (Options.LogAnnotationSetInfo)
337-
{
338-
Logger?.CommentSetHeader(description, headerName, headerValue);
339-
}
330+
Logger?.CommentSetHeader(description, headerName, headerValue);
340331
}
341332
}
342333
}
@@ -429,10 +420,7 @@ internal static class DefaultCommentParser
429420
}
430421
if (routineEndpoint.Method != originalMethod || !string.Equals(routineEndpoint.Path, originalUrl))
431422
{
432-
if (Options.LogAnnotationSetInfo)
433-
{
434-
Logger?.CommentSetHttp(description, routineEndpoint.Method, routineEndpoint.Path);
435-
}
423+
Logger?.CommentSetHttp(description, routineEndpoint.Method, routineEndpoint.Path);
436424
urlDescription = string.Concat(routineEndpoint.Method.ToString(), " ", routineEndpoint.Path);
437425
description = string.Concat(routineDescription, " mapped to ", urlDescription);
438426
}
@@ -456,10 +444,7 @@ internal static class DefaultCommentParser
456444
routineEndpoint.Path = string.Concat("/", routineEndpoint.Path);
457445
}
458446

459-
if (Options.LogAnnotationSetInfo)
460-
{
461-
Logger?.CommentSetHttp(description, routineEndpoint.Method, routineEndpoint.Path);
462-
}
447+
Logger?.CommentSetHttp(description, routineEndpoint.Method, routineEndpoint.Path);
463448
urlDescription = string.Concat(routineEndpoint.Method.ToString(), " ", routineEndpoint.Path);
464449
description = string.Concat(routineDescription, " mapped to ", urlDescription);
465450
}
@@ -485,10 +470,7 @@ internal static class DefaultCommentParser
485470

486471
if (originalParamType != routineEndpoint.RequestParamType)
487472
{
488-
if (Options.LogAnnotationSetInfo)
489-
{
490-
Logger?.CommentSetParameterType(description, routineEndpoint.RequestParamType);
491-
}
473+
Logger?.CommentSetParameterType(description, routineEndpoint.RequestParamType);
492474
}
493475
}
494476

@@ -502,17 +484,11 @@ internal static class DefaultCommentParser
502484
if (wordsLower.Length > 1)
503485
{
504486
routineEndpoint.AuthorizeRoles = [.. wordsLower[1..]];
505-
if (Options.LogAnnotationSetInfo)
506-
{
507-
Logger?.CommentSetAuthRoles(description, routineEndpoint.AuthorizeRoles);
508-
}
487+
Logger?.CommentSetAuthRoles(description, routineEndpoint.AuthorizeRoles);
509488
}
510489
else
511490
{
512-
if (Options.LogAnnotationSetInfo)
513-
{
514-
Logger?.CommentSetAuth(description);
515-
}
491+
Logger?.CommentSetAuth(description);
516492
}
517493
}
518494

@@ -523,10 +499,7 @@ internal static class DefaultCommentParser
523499
else if (haveTag is true && StrEqualsToArray(wordsLower[0], AllowAnonymousKey))
524500
{
525501
routineEndpoint.RequiresAuthorization = false;
526-
if (Options.LogAnnotationSetInfo)
527-
{
528-
Logger?.CommentSetAnon(description);
529-
}
502+
Logger?.CommentSetAnon(description);
530503
}
531504

532505
// command_timeout interval
@@ -540,10 +513,7 @@ internal static class DefaultCommentParser
540513
}
541514
else if (routineEndpoint.CommandTimeout != parsedInterval)
542515
{
543-
if (Options.LogAnnotationSetInfo)
544-
{
545-
Logger?.CommentSetTimeout(description, parsedInterval);
546-
}
516+
Logger?.CommentSetTimeout(description, parsedInterval);
547517
}
548518
routineEndpoint.CommandTimeout = parsedInterval;
549519
}
@@ -570,10 +540,7 @@ internal static class DefaultCommentParser
570540
}
571541
if (routineEndpoint.RequestHeadersMode != Options.RequestHeadersMode)
572542
{
573-
if (Options.LogAnnotationSetInfo)
574-
{
575-
Logger?.CommentSetRequestHeadersMode(description, wordsLower[1]);
576-
}
543+
Logger?.CommentSetRequestHeadersMode(description, wordsLower[1]);
577544
}
578545
}
579546

@@ -585,10 +552,7 @@ internal static class DefaultCommentParser
585552
{
586553
if (!string.Equals(routineEndpoint.RequestHeadersParameterName, wordsLower[1]))
587554
{
588-
if (Options.LogAnnotationSetInfo)
589-
{
590-
Logger?.CommentSetRequestHeadersParamName(description, wordsLower[1]);
591-
}
555+
Logger?.CommentSetRequestHeadersParamName(description, wordsLower[1]);
592556
}
593557
routineEndpoint.RequestHeadersParameterName = wordsLower[1];
594558
}
@@ -602,10 +566,7 @@ internal static class DefaultCommentParser
602566
{
603567
if (!string.Equals(routineEndpoint.BodyParameterName, wordsLower[1]))
604568
{
605-
if (Options.LogAnnotationSetInfo)
606-
{
607-
Logger?.CommentSetBodyParamName(description, wordsLower[1]);
608-
}
569+
Logger?.CommentSetBodyParamName(description, wordsLower[1]);
609570
}
610571
routineEndpoint.BodyParameterName = wordsLower[1];
611572
}
@@ -633,10 +594,7 @@ internal static class DefaultCommentParser
633594
}
634595
if (routineEndpoint.TextResponseNullHandling != Options.TextResponseNullHandling)
635596
{
636-
if (Options.LogAnnotationSetInfo)
637-
{
638-
Logger?.CommentSetTextResponseNullHandling(description, wordsLower[1]);
639-
}
597+
Logger?.CommentSetTextResponseNullHandling(description, wordsLower[1]);
640598
}
641599
}
642600

@@ -664,10 +622,7 @@ internal static class DefaultCommentParser
664622
}
665623
if (routineEndpoint.TextResponseNullHandling != Options.TextResponseNullHandling)
666624
{
667-
if (Options.LogAnnotationSetInfo)
668-
{
669-
Logger?.CommentSetQueryStringNullHandling(description, routineEndpoint.QueryStringNullHandling);
670-
}
625+
Logger?.CommentSetQueryStringNullHandling(description, routineEndpoint.QueryStringNullHandling);
671626
}
672627
}
673628

@@ -676,21 +631,15 @@ internal static class DefaultCommentParser
676631
else if (haveTag is true && StrEqualsToArray(wordsLower[0], LoginKey))
677632
{
678633
routineEndpoint.Login = true;
679-
if (Options.LogAnnotationSetInfo)
680-
{
681-
Logger?.CommentSetLogin(description);
682-
}
634+
Logger?.CommentSetLogin(description);
683635
}
684636

685637
// logout
686638
// signout
687639
else if (haveTag is true && StrEqualsToArray(wordsLower[0], LogoutKey))
688640
{
689641
routineEndpoint.Logout = true;
690-
if (Options.LogAnnotationSetInfo)
691-
{
692-
Logger?.CommentSetLogout(description);
693-
}
642+
Logger?.CommentSetLogout(description);
694643
}
695644

696645
// buffer_rows number
@@ -701,10 +650,7 @@ internal static class DefaultCommentParser
701650
{
702651
if (routineEndpoint.BufferRows != parsedBuffer)
703652
{
704-
if (Options.LogAnnotationSetInfo)
705-
{
706-
Logger?.CommentBufferRows(description, wordsLower[1]);
707-
}
653+
Logger?.CommentBufferRows(description, wordsLower[1]);
708654
}
709655
routineEndpoint.BufferRows = parsedBuffer;
710656
}
@@ -749,42 +695,30 @@ internal static class DefaultCommentParser
749695
else if (haveTag is true && StrEqualsToArray(wordsLower[0], ColumnNamesKey))
750696
{
751697
routineEndpoint.RawColumnNames = true;
752-
if (Options.LogAnnotationSetInfo)
753-
{
754-
Logger?.CommentRawSetColumnNames(description);
755-
}
698+
Logger?.CommentRawSetColumnNames(description);
756699
}
757700

758701
// sensitive
759702
// security_sensitive
760703
else if (haveTag is true && StrEqualsToArray(wordsLower[0], SecuritySensitiveKey))
761704
{
762705
routineEndpoint.SecuritySensitive = true;
763-
if (Options.LogAnnotationSetInfo)
764-
{
765-
Logger?.CommentSecuritySensitive(description);
766-
}
706+
Logger?.CommentSecuritySensitive(description);
767707
}
768708

769709
// user_context
770710
else if (haveTag is true && StrEqualsToArray(wordsLower[0], UserContextKey))
771711
{
772712
routineEndpoint.UserContext = true;
773-
if (Options.LogAnnotationSetInfo)
774-
{
775-
Logger?.CommentUserContext(description);
776-
}
713+
Logger?.CommentUserContext(description);
777714
}
778715

779716
// user_parameters
780717
// user_params
781718
else if (haveTag is true && StrEqualsToArray(wordsLower[0], UserParemetersKey))
782719
{
783720
routineEndpoint.UseUserParameters = true;
784-
if (Options.LogAnnotationSetInfo)
785-
{
786-
Logger?.CommentUserParameters(description);
787-
}
721+
Logger?.CommentUserParameters(description);
788722
}
789723

790724
// cached
@@ -815,10 +749,7 @@ internal static class DefaultCommentParser
815749
routineEndpoint.CachedParams = result;
816750
}
817751

818-
if (Options.LogAnnotationSetInfo)
819-
{
820-
Logger?.CommentCached(description, routineEndpoint.CachedParams ?? []);
821-
}
752+
Logger?.CommentCached(description, routineEndpoint.CachedParams ?? []);
822753
}
823754

824755
// cache_expires [ value ]
@@ -829,10 +760,7 @@ internal static class DefaultCommentParser
829760
if (value is not null)
830761
{
831762
routineEndpoint.CacheExpiresIn = value.Value;
832-
if (Options.LogAnnotationSetInfo)
833-
{
834-
Logger?.CommentCacheExpiresIn(description, value.Value);
835-
}
763+
Logger?.CommentCacheExpiresIn(description, value.Value);
836764
}
837765
else
838766
{
@@ -852,10 +780,7 @@ internal static class DefaultCommentParser
852780
Logger?.CommentInvalidConnectionName(description, name);
853781
}
854782
routineEndpoint.ConnectionName = name;
855-
if (Options.LogAnnotationSetInfo)
856-
{
857-
Logger?.CommentConnectionName(description, name);
858-
}
783+
Logger?.CommentConnectionName(description, name);
859784
}
860785
else
861786
{
@@ -877,10 +802,7 @@ internal static class DefaultCommentParser
877802
if (routineEndpoint.Upload is false)
878803
{
879804
routineEndpoint.Upload = true;
880-
if (Options.LogAnnotationSetInfo)
881-
{
882-
Logger?.CommentUpload(description);
883-
}
805+
Logger?.CommentUpload(description);
884806
}
885807
if (routineEndpoint.RequestParamType != RequestParamType.QueryString)
886808
{
@@ -910,21 +832,18 @@ internal static class DefaultCommentParser
910832
.ToArray();
911833

912834
routineEndpoint.UploadHandlers = handlers;
913-
if (Options.LogAnnotationSetInfo)
835+
if (handlers.Length == 0)
914836
{
915-
if (handlers.Length == 0)
916-
{
917-
var first = Options.UploadOptions.UploadHandlers?.Keys.FirstOrDefault();
918-
Logger?.CommentUploadFirstAvaialbleHandler(description, first);
919-
}
920-
if (handlers.Length == 1)
921-
{
922-
Logger?.CommentUploadSingleHandler(description, handlers[0]);
923-
}
924-
else
925-
{
926-
Logger?.CommentUploadHandlers(description, handlers);
927-
}
837+
var first = Options.UploadOptions.UploadHandlers?.Keys.FirstOrDefault();
838+
Logger?.CommentUploadFirstAvaialbleHandler(description, first);
839+
}
840+
if (handlers.Length == 1)
841+
{
842+
Logger?.CommentUploadSingleHandler(description, handlers[0]);
843+
}
844+
else
845+
{
846+
Logger?.CommentUploadHandlers(description, handlers);
928847
}
929848
}
930849

@@ -941,10 +860,7 @@ internal static class DefaultCommentParser
941860
else
942861
{
943862
param.IsUploadMetadata = true;
944-
if (Options.LogAnnotationSetInfo)
945-
{
946-
Logger?.CommentUploadMetadataParam(description, paramName);
947-
}
863+
Logger?.CommentUploadMetadataParam(description, paramName);
948864
}
949865
}
950866
}
@@ -994,10 +910,7 @@ internal static class DefaultCommentParser
994910
}
995911
else
996912
{
997-
if (Options.LogAnnotationSetInfo)
998-
{
999-
Logger?.CommentParamIsHashOf(description, paramName1, paramName2);
1000-
}
913+
Logger?.CommentParamIsHashOf(description, paramName1, paramName2);
1001914
}
1002915
}
1003916
else
@@ -1015,10 +928,7 @@ internal static class DefaultCommentParser
1015928
if (routineEndpoint.Upload is false)
1016929
{
1017930
routineEndpoint.Upload = true;
1018-
if (Options.LogAnnotationSetInfo)
1019-
{
1020-
Logger?.CommentUpload(description);
1021-
}
931+
Logger?.CommentUpload(description);
1022932
}
1023933
if (routineEndpoint.RequestParamType != RequestParamType.QueryString)
1024934
{
@@ -1040,10 +950,7 @@ internal static class DefaultCommentParser
1040950
else
1041951
{
1042952
param.IsUploadMetadata = true;
1043-
if (Options.LogAnnotationSetInfo)
1044-
{
1045-
Logger?.CommentUploadMetadataParam(description, paramName);
1046-
}
953+
Logger?.CommentUploadMetadataParam(description, paramName);
1047954
}
1048955
}
1049956
}
@@ -1190,10 +1097,7 @@ internal static class DefaultCommentParser
11901097
}
11911098
if (disabled)
11921099
{
1193-
if (Options.LogAnnotationSetInfo)
1194-
{
1195-
Logger?.CommentDisabled(description);
1196-
}
1100+
Logger?.CommentDisabled(description);
11971101
return null;
11981102
}
11991103
if (Options.CommentsMode == CommentsMode.OnlyWithHttpTag && !hasHttpTag)

0 commit comments

Comments
 (0)