Skip to content

Commit 2390669

Browse files
authored
Merge branch 'master' into updates
2 parents 9c45cb5 + e79b88e commit 2390669

File tree

19 files changed

+51
-37
lines changed

19 files changed

+51
-37
lines changed

benchmarks/Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
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/Startup.cs

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<ProjectReference Include="../../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
11-
<ProjectReference Include="..\JsonApiDotNetCoreExample\JsonApiDotNetCoreExample.csproj" />
11+
<ProjectReference Include="../JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

src/Examples/OperationsExample/Startup.cs

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 8 additions & 3 deletions
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
}

0 commit comments

Comments
 (0)