5
5
using JsonApiDotNetCore . Exceptions ;
6
6
using JsonApiDotNetCore . Query ;
7
7
using JsonApiDotNetCore . QueryParameterServices . Common ;
8
+ using Microsoft . Extensions . Logging ;
8
9
9
10
namespace JsonApiDotNetCore . Services
10
11
{
@@ -14,12 +15,15 @@ public class QueryParameterParser : IQueryParameterParser
14
15
private readonly IJsonApiOptions _options ;
15
16
private readonly IRequestQueryStringAccessor _queryStringAccessor ;
16
17
private readonly IEnumerable < IQueryParameterService > _queryServices ;
18
+ private ILogger < QueryParameterParser > _logger ;
17
19
18
- public QueryParameterParser ( IJsonApiOptions options , IRequestQueryStringAccessor queryStringAccessor , IEnumerable < IQueryParameterService > queryServices )
20
+ public QueryParameterParser ( IJsonApiOptions options , IRequestQueryStringAccessor queryStringAccessor , IEnumerable < IQueryParameterService > queryServices , ILoggerFactory loggerFactory )
19
21
{
20
22
_options = options ;
21
23
_queryStringAccessor = queryStringAccessor ;
22
24
_queryServices = queryServices ;
25
+
26
+ _logger = loggerFactory . CreateLogger < QueryParameterParser > ( ) ;
23
27
}
24
28
25
29
/// <inheritdoc/>
@@ -38,6 +42,8 @@ public virtual void Parse(DisableQueryAttribute disableQueryAttribute)
38
42
var service = _queryServices . FirstOrDefault ( s => s . CanParse ( pair . Key ) ) ;
39
43
if ( service != null )
40
44
{
45
+ _logger . LogDebug ( $ "Query string parameter '{ pair . Key } ' with value '{ pair . Value } ' was accepted by { service . GetType ( ) . Name } .") ;
46
+
41
47
if ( ! service . IsEnabled ( disableQueryAttribute ) )
42
48
{
43
49
throw new InvalidQueryStringParameterException ( pair . Key ,
@@ -46,6 +52,7 @@ public virtual void Parse(DisableQueryAttribute disableQueryAttribute)
46
52
}
47
53
48
54
service . Parse ( pair . Key , pair . Value ) ;
55
+ _logger . LogDebug ( $ "Query string parameter '{ pair . Key } ' was successfully parsed.") ;
49
56
}
50
57
else if ( ! _options . AllowCustomQueryStringParameters )
51
58
{
0 commit comments