Skip to content

Commit 8fd7d3b

Browse files
authored
Merge branch 'master' into feat/#281
2 parents 101fe85 + e79b88e commit 8fd7d3b

File tree

20 files changed

+51
-39
lines changed

20 files changed

+51
-39
lines changed

benchmarks/Benchmarks.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<PackageReference Include="xunit" Version="$(xUnitVersion)" />
1111
</ItemGroup>
1212
<ItemGroup>
13-
<ProjectReference Include="..\src\JsonApiDotNetCore\JsonApiDotNetCore.csproj" />
13+
<ProjectReference Include="../src/JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
1414
</ItemGroup>
1515
</Project>

src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@
2828
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreToolsVersion)" />
2929
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlPostgreSQLVersion)" />
3030
</ItemGroup>
31-
3231
</Project>

src/Examples/JsonApiDotNetCoreExample/Startup.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public Startup(IHostingEnvironment env)
2828
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
2929
{
3030
var loggerFactory = new LoggerFactory();
31-
loggerFactory.AddConsole(LogLevel.Trace);
31+
loggerFactory.AddConsole(LogLevel.Warning);
3232

3333
services
3434
.AddSingleton<ILoggerFactory>(loggerFactory)
@@ -57,7 +57,6 @@ public virtual void Configure(
5757
context.Database.EnsureCreated();
5858

5959
loggerFactory.AddConsole(Config.GetSection("Logging"));
60-
loggerFactory.AddDebug();
6160

6261
app.UseJsonApi();
6362
}

src/Examples/JsonApiDotNetCoreExample/appsettings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"Logging": {
66
"IncludeScopes": false,
77
"LogLevel": {
8-
"Default": "Trace",
9-
"System": "Trace",
10-
"Microsoft": "Trace"
8+
"Default": "Warning",
9+
"System": "Warning",
10+
"Microsoft": "Warning"
1111
}
1212
}
1313
}

src/Examples/NoEntityFrameworkExample/Startup.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using JsonApiDotNetCore.Extensions;
1+
using JsonApiDotNetCore.Extensions;
22
using JsonApiDotNetCore.Services;
33
using JsonApiDotNetCoreExample.Data;
44
using JsonApiDotNetCoreExample.Models;
@@ -55,7 +55,6 @@ public virtual IServiceProvider ConfigureServices(IServiceCollection services)
5555
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AppDbContext context)
5656
{
5757
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
58-
loggerFactory.AddDebug();
5958

6059
context.Database.EnsureCreated();
6160

src/Examples/OperationsExample/OperationsExample.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<ProjectReference Include="../../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
14-
<ProjectReference Include="..\JsonApiDotNetCoreExample\JsonApiDotNetCoreExample.csproj" />
14+
<ProjectReference Include="../JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj" />
1515
</ItemGroup>
1616

1717
<ItemGroup>
@@ -29,5 +29,4 @@
2929
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreToolsVersion)" />
3030
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlPostgreSQLVersion)" />
3131
</ItemGroup>
32-
3332
</Project>

src/Examples/OperationsExample/Startup.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Startup(IHostingEnvironment env)
2727
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
2828
{
2929
var loggerFactory = new LoggerFactory();
30-
loggerFactory.AddConsole(LogLevel.Trace);
30+
loggerFactory.AddConsole(LogLevel.Warning);
3131

3232
services.AddSingleton<ILoggerFactory>(loggerFactory);
3333

@@ -47,7 +47,6 @@ public virtual void Configure(
4747
context.Database.EnsureCreated();
4848

4949
loggerFactory.AddConsole(Config.GetSection("Logging"));
50-
loggerFactory.AddDebug();
5150
app.UseJsonApi();
5251
}
5352

src/Examples/OperationsExample/appsettings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"Logging": {
66
"IncludeScopes": false,
77
"LogLevel": {
8-
"Default": "Trace",
9-
"System": "Trace",
10-
"Microsoft": "Trace"
8+
"Default": "Warning",
9+
"System": "Warning",
10+
"Microsoft": "Warning"
1111
}
1212
}
1313
}

src/Examples/ReportsExample/appsettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Logging": {
33
"IncludeScopes": false,
44
"LogLevel": {
5-
"Default": "Information"
5+
"Default": "Warning"
66
}
77
}
88
}

src/JsonApiDotNetCore/Serialization/JsonApiSerializer.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ private string GetErrorJson(object responseObject, ILogger logger)
6565
}
6666
else
6767
{
68-
logger?.LogInformation("Response was not a JSONAPI entity. Serializing as plain JSON.");
68+
if (logger?.IsEnabled(LogLevel.Information) == true)
69+
{
70+
logger.LogInformation("Response was not a JSONAPI entity. Serializing as plain JSON.");
71+
}
72+
6973
return JsonConvert.SerializeObject(responseObject);
7074
}
7175
}

src/JsonApiDotNetCore/Services/EntityResourceService.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ public virtual async Task<object> GetRelationshipAsync(TId id, string relationsh
8989

9090
if (relationshipName == null)
9191
throw new JsonApiException(422, "Relationship name not specified.");
92-
93-
_logger.LogTrace($"Looking up '{relationshipName}'...");
92+
if (_logger.IsEnabled(LogLevel.Trace))
93+
{
94+
_logger.LogTrace($"Looking up '{relationshipName}'...");
95+
}
9496

9597
var entity = await _entities.GetAndIncludeAsync(id, relationshipName);
9698
// TODO: it would be better if we could distinguish whether or not the relationship was not found,
@@ -166,7 +168,10 @@ protected virtual async Task<IEnumerable<T>> ApplyPageQueryAsync(IQueryable<T> e
166168
if (!pageManager.IsPaginated)
167169
return await _entities.ToListAsync(entities);
168170

169-
_logger?.LogInformation($"Applying paging query. Fetching page {pageManager.CurrentPage} with {pageManager.PageSize} entities");
171+
if (_logger?.IsEnabled(LogLevel.Information) == true)
172+
{
173+
_logger?.LogInformation($"Applying paging query. Fetching page {pageManager.CurrentPage} with {pageManager.PageSize} entities");
174+
}
170175

171176
return await _entities.PageAsync(entities, pageManager.PageSize, pageManager.CurrentPage);
172177
}

src/JsonApiDotNetCore/Services/QueryAccessor.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public bool TryGetValue<T>(string key, out T value)
4545
var stringValue = GetFilterValue(key);
4646
if (stringValue == null)
4747
{
48-
_logger.LogInformation($"'{key}' was not found in the query collection");
48+
if (_logger.IsEnabled(LogLevel.Information))
49+
{
50+
_logger.LogInformation($"'{key}' was not found in the query collection");
51+
}
52+
4953
return false;
5054
}
5155

@@ -56,7 +60,12 @@ public bool TryGetValue<T>(string key, out T value)
5660
}
5761
catch (FormatException)
5862
{
59-
_logger.LogInformation($"'{value}' is not a valid '{typeof(T).Name}' value for query parameter {key}");
63+
if (_logger.IsEnabled(LogLevel.Information))
64+
{
65+
_logger.LogInformation(
66+
$"'{value}' is not a valid '{typeof(T).Name}' value for query parameter {key}");
67+
}
68+
6069
return false;
6170
}
6271
}

test/JsonApiDotNetCoreExampleTests/Helpers/Startups/MetaStartup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public MetaStartup(IHostingEnvironment env)
2020
public override IServiceProvider ConfigureServices(IServiceCollection services)
2121
{
2222
var loggerFactory = new LoggerFactory();
23-
loggerFactory.AddConsole(LogLevel.Trace);
23+
loggerFactory.AddConsole(LogLevel.Warning);
2424

2525
services
2626
.AddSingleton<ILoggerFactory>(loggerFactory)

test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@
2929

3030
<ItemGroup>
3131
<DotNetCliToolReference Include="dotnet-xunit" Version="$(XUnitVersion)" />
32-
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
3332
</ItemGroup>
3433
</Project>

test/JsonApiDotNetCoreExampleTests/appsettings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"Logging": {
66
"IncludeScopes": false,
77
"LogLevel": {
8-
"Default": "Error",
9-
"System": "Information",
10-
"Microsoft": "Information"
8+
"Default": "Warning",
9+
"System": "Warning",
10+
"Microsoft": "Warning"
1111
}
1212
}
1313
}

test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ProjectReference Include="../../src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj" />
1919
<ProjectReference Include="../../test/JsonApiDotNetCoreExampleTests/JsonApiDotNetCoreExampleTests.csproj" />
2020
<ProjectReference Include="../../src/Examples/NoEntityFrameworkExample/NoEntityFrameworkExample.csproj" />
21-
<ProjectReference Include="..\UnitTests\UnitTests.csproj" />
21+
<ProjectReference Include="../UnitTests/UnitTests.csproj" />
2222
</ItemGroup>
2323
<ItemGroup>
2424
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />

test/NoEntityFrameworkTests/appsettings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"Logging": {
66
"IncludeScopes": false,
77
"LogLevel": {
8-
"Default": "Debug",
9-
"System": "Information",
10-
"Microsoft": "Information"
8+
"Default": "Warning",
9+
"System": "Warning",
10+
"Microsoft": "Warning"
1111
}
1212
}
1313
}

test/OperationsExampleTests/OperationsExampleTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
1515
</ItemGroup>
1616
<ItemGroup>
17-
<ProjectReference Include="..\..\src\Examples\OperationsExample\OperationsExample.csproj" />
18-
<ProjectReference Include="..\UnitTests\UnitTests.csproj" />
17+
<ProjectReference Include="../../src/Examples/OperationsExample/OperationsExample.csproj" />
18+
<ProjectReference Include="../UnitTests/UnitTests.csproj" />
1919
</ItemGroup>
2020
<ItemGroup>
2121
<None Update="xunit.runner.json;appsettings.json">

test/OperationsExampleTests/appsettings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"Logging": {
66
"IncludeScopes": false,
77
"LogLevel": {
8-
"Default": "Trace",
9-
"System": "Trace",
10-
"Microsoft": "Trace"
8+
"Default": "Warning",
9+
"System": "Warning",
10+
"Microsoft": "Warning"
1111
}
1212
}
1313
}

test/UnitTests/UnitTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99
<ItemGroup>
10-
<ProjectReference Include="..\..\src\JsonApiDotNetCore\JsonApiDotNetCore.csproj" />
11-
<ProjectReference Include="..\..\src\Examples\JsonApiDotNetCoreExample\JsonApiDotNetCoreExample.csproj" />
10+
<ProjectReference Include="../../src/JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
11+
<ProjectReference Include="../../src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj" />
1212
</ItemGroup>
1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />

0 commit comments

Comments
 (0)