Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="8.3.10" />
<PackageReference Include="Shared" Version="2024.5.1" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.3" />
<PackageReference Include="Shared" Version="2024.7.1" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.5" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions EstateReportingAPI.BusinessLogic/ReportingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,7 @@ public async Task<List<Operator>> GetOperators(Guid estateId, CancellationToken
{
Name = o.Name,
EstateReportingId = context.Estates.Single(e => e.EstateId == o.EstateId).EstateReportingId,
OperatorId = o.OperatorId,
OperatorReportingId = o.OperatorReportingId
OperatorId = o.OperatorId
}).ToListAsync(cancellationToken);

return operators;
Expand Down
2 changes: 1 addition & 1 deletion EstateReportingAPI.Client/EstateReportingAPI.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2024.5.1" />
<PackageReference Include="ClientProxyBase" Version="2024.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.Database" Version="2024.6.3" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
Expand All @@ -23,8 +23,8 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="Shared" Version="2024.5.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.5.1" />
<PackageReference Include="Shared" Version="2024.7.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.7.1" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
Expand Down
35 changes: 34 additions & 1 deletion EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace EstateReportingAPI.Bootstrapper{
using Shared.Middleware;

namespace EstateReportingAPI.Bootstrapper{
using System.Diagnostics.CodeAnalysis;
using System.Net.Security;
using System.Reflection;
Expand Down Expand Up @@ -88,6 +90,15 @@ public MiddlewareRegistry(){

Assembly assembly = this.GetType().GetTypeInfo().Assembly;
this.AddMvcCore().AddApplicationPart(assembly).AddControllersAsServices();

bool logRequests = ConfigurationReaderExtensions.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogRequests", true);
bool logResponses = ConfigurationReaderExtensions.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogResponses", true);
LogLevel middlewareLogLevel = ConfigurationReaderExtensions.GetValueOrDefault<LogLevel>("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning);

RequestResponseMiddlewareLoggingConfig config =
new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses);

this.AddSingleton(config);
}

private HttpClientHandler ApiEndpointHttpHandler(IServiceProvider serviceProvider){
Expand All @@ -101,4 +112,26 @@ private HttpClientHandler ApiEndpointHttpHandler(IServiceProvider serviceProvide
};
}
}

public static class ConfigurationReaderExtensions
{
public static T GetValueOrDefault<T>(String sectionName, String keyName, T defaultValue)
{
try
{
var value = ConfigurationReader.GetValue(sectionName, keyName);

if (String.IsNullOrEmpty(value))
{
return defaultValue;
}

return (T)Convert.ChangeType(value, typeof(T));
}
catch (KeyNotFoundException kex)
{
return defaultValue;
}
}
}
}
4 changes: 2 additions & 2 deletions EstateReportingAPI/EstateReportingAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.Database" Version="2024.6.3" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.5" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
Expand All @@ -19,7 +19,7 @@
<PackageReference Include="Lamar" Version="13.0.3" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="13.0.3" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="Shared" Version="2024.5.1" />
<PackageReference Include="Shared" Version="2024.7.1" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.0" />
Expand Down
12 changes: 6 additions & 6 deletions EstateReportingAPI/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF

if (env.IsDevelopment())
{
var developmentNlogConfigFilename = "nlog.development.config";
if (File.Exists(Path.Combine(env.ContentRootPath, developmentNlogConfigFilename)))
{
nlogConfigFilename = developmentNlogConfigFilename;
}
app.UseDeveloperExceptionPage();
}

Expand All @@ -72,12 +77,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
Microsoft.Extensions.Logging.ILogger logger = loggerFactory.CreateLogger("EstateManagement");

Logger.Initialise(logger);

Action<string> loggerAction = message =>
{
Logger.LogInformation(message);
};
Configuration.LogConfiguration(loggerAction);
Configuration.LogConfiguration(Logger.LogWarning);

ConfigurationReader.Initialise(Configuration);

Expand Down
15 changes: 12 additions & 3 deletions EstateReportingAPI/nlog.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@
</target>
</targets>

<!--
Trace - Very detailed log messages, potentially of a high frequency and volume
Debug -Less detailed and/or less frequent debugging messages
Info - Informational messages
Warn - Warnings which don't appear to the user of the application
Error - Error messages
Fatal - Fatal error messages. After a fatal error, the application usually terminates
-->

<rules>
<logger name="Microsoft.*" minlevel="Debug" writeTo="" final="true" />
<logger name="*" minlevel="Debug" writeTo="logfile">
<logger name="Microsoft.*" minlevel="Warn" writeTo="" final="true" />
<logger name="*" minlevel="Warn" writeTo="logfile">
<filters defaultAction="Log">
<when condition="contains('${message}', 'HEALTH_CHECK')" action="Ignore"></when>
</filters>
</logger>
<logger name="*" minlevel="Debug" writeTo="healthlogfile">
<logger name="*" minlevel="Warn" writeTo="healthlogfile">
<filters defaultAction="Ignore">
<when condition="contains('${message}', 'HEALTH_CHECK')" action="Log"></when>
</filters>
Expand Down