Skip to content

Commit

Permalink
Separate Atlas.Core.Logging interface from Serilogs implementation #16
Browse files Browse the repository at this point in the history
Renamed Atlas.Core.Logging to Atlas.Logging for interfaces only, and created Atlas.Logging.Serilogs for Serilogs implementation #16
  • Loading branch information
grantcolley committed Dec 26, 2024
1 parent 48f2a96 commit 4f71b61
Show file tree
Hide file tree
Showing 31 changed files with 133 additions and 114 deletions.
21 changes: 14 additions & 7 deletions Atlas.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atlas.Blazor.Web.App.Client
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atlas.Blazor.Web", "src\Atlas.Blazor.Web\Atlas.Blazor.Web.csproj", "{1DA30BB5-2943-42AF-B810-E6E220D658F7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atlas.Core.Logging", "src\Atlas.Core.Logging\Atlas.Core.Logging.csproj", "{D2F67554-D276-4C6D-B033-DC5480F725BA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", "{5EF3D9C7-E877-425B-95A7-2C21A7407EC6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utility", "utility", "{881E7D01-54E2-4752-BDCF-BEC0D8825534}"
Expand All @@ -37,6 +35,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlas.Data.Access.EF", "src
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlas.Data.Access.EF.Context", "src\Atlas.Data.Access.EF.Context\Atlas.Data.Access.EF.Context.csproj", "{25952631-4DAD-49A7-B4C7-F819F13CC555}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlas.Logging", "src\Atlas.Logging\Atlas.Logging.csproj", "{C6680503-010B-4AC1-BB2C-D8856E325168}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlas.Logging.Serilog", "src\Atlas.Logging.Serilog\Atlas.Logging.Serilog.csproj", "{8CE1F8A2-40D3-45CC-9B2D-DC526394A8E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -71,10 +73,6 @@ Global
{1DA30BB5-2943-42AF-B810-E6E220D658F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DA30BB5-2943-42AF-B810-E6E220D658F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DA30BB5-2943-42AF-B810-E6E220D658F7}.Release|Any CPU.Build.0 = Release|Any CPU
{D2F67554-D276-4C6D-B033-DC5480F725BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2F67554-D276-4C6D-B033-DC5480F725BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2F67554-D276-4C6D-B033-DC5480F725BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2F67554-D276-4C6D-B033-DC5480F725BA}.Release|Any CPU.Build.0 = Release|Any CPU
{CF4F5023-BD96-4A8D-A331-1AF6073CAA84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF4F5023-BD96-4A8D-A331-1AF6073CAA84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF4F5023-BD96-4A8D-A331-1AF6073CAA84}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -99,6 +97,14 @@ Global
{25952631-4DAD-49A7-B4C7-F819F13CC555}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25952631-4DAD-49A7-B4C7-F819F13CC555}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25952631-4DAD-49A7-B4C7-F819F13CC555}.Release|Any CPU.Build.0 = Release|Any CPU
{C6680503-010B-4AC1-BB2C-D8856E325168}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6680503-010B-4AC1-BB2C-D8856E325168}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6680503-010B-4AC1-BB2C-D8856E325168}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6680503-010B-4AC1-BB2C-D8856E325168}.Release|Any CPU.Build.0 = Release|Any CPU
{8CE1F8A2-40D3-45CC-9B2D-DC526394A8E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CE1F8A2-40D3-45CC-9B2D-DC526394A8E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CE1F8A2-40D3-45CC-9B2D-DC526394A8E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CE1F8A2-40D3-45CC-9B2D-DC526394A8E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -111,13 +117,14 @@ Global
{603C00D0-2857-4920-947D-8EBFEC3139EF} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{B24B2EDB-C484-4942-973E-E6510DCA6F9D} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{1DA30BB5-2943-42AF-B810-E6E220D658F7} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{D2F67554-D276-4C6D-B033-DC5480F725BA} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{CF4F5023-BD96-4A8D-A331-1AF6073CAA84} = {881E7D01-54E2-4752-BDCF-BEC0D8825534}
{68D4AF69-D350-4515-AD53-9419D09643B0} = {5EF3D9C7-E877-425B-95A7-2C21A7407EC6}
{5FA5960E-01B3-4567-8F19-70A8AA743FE1} = {5EF3D9C7-E877-425B-95A7-2C21A7407EC6}
{944113A7-49EA-4B68-917B-B9AC56D1FC12} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{5B96B25D-0228-4D3E-8EE1-D1D9036796E7} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{25952631-4DAD-49A7-B4C7-F819F13CC555} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{C6680503-010B-4AC1-BB2C-D8856E325168} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
{8CE1F8A2-40D3-45CC-9B2D-DC526394A8E4} = {4D561DB1-6F2C-4895-88D3-91379F9CFEE6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {35D4493E-72A3-403D-AB40-7AADFBC20D09}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Message = table.Column<string>(type: "nvarchar(450)", nullable: true),
Message = table.Column<string>(type: "nvarchar(max)", nullable: true),
MessageTemplate = table.Column<string>(type: "nvarchar(max)", nullable: true),
Level = table.Column<string>(type: "nvarchar(max)", nullable: true),
TimeStamp = table.Column<DateTime>(type: "datetime2", nullable: true),
Expand Down Expand Up @@ -245,11 +245,6 @@ protected override void Up(MigrationBuilder migrationBuilder)
table: "Logs",
column: "Context");

migrationBuilder.CreateIndex(
name: "IX_Logs_Message",
table: "Logs",
column: "Message");

migrationBuilder.CreateIndex(
name: "IX_Logs_TimeStamp",
table: "Logs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("nvarchar(max)");

b.Property<string>("Message")
.HasColumnType("nvarchar(450)");
.HasColumnType("nvarchar(max)");

b.Property<string>("MessageTemplate")
.HasColumnType("nvarchar(max)");
Expand All @@ -111,8 +111,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("Context");

b.HasIndex("Message");

b.HasIndex("TimeStamp");

b.HasIndex("User");
Expand Down
9 changes: 5 additions & 4 deletions src/Atlas.API/Atlas.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="8.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
</ItemGroup>

Expand All @@ -32,8 +32,9 @@
<ProjectReference Include="..\..\migrations\Atlas.Migrations.SQLServer\Atlas.Migrations.SQLServer.csproj" />
<ProjectReference Include="..\Atlas.Core.Validation\Atlas.Core.Validation.csproj" />
<ProjectReference Include="..\Atlas.Core\Atlas.Core.csproj" />
<ProjectReference Include="..\Atlas.Core.Logging\Atlas.Core.Logging.csproj" />
<ProjectReference Include="..\Atlas.Data.Access.EF\Atlas.Data.Access.EF.csproj" />
<ProjectReference Include="..\Atlas.Logging.Serilog\Atlas.Logging.Serilog.csproj" />
<ProjectReference Include="..\Atlas.Logging\Atlas.Logging.csproj" />
</ItemGroup>

</Project>
36 changes: 18 additions & 18 deletions src/Atlas.API/Endpoints/AdministrationEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using Atlas.API.Utility;
using Atlas.Core.Constants;
using Atlas.Core.Exceptions;
using Atlas.Core.Logging.Interfaces;
using Atlas.Core.Models;
using Atlas.Data.Access.Interfaces;
using Atlas.Logging.Interfaces;
using FluentValidation;
using Microsoft.AspNetCore.Mvc;

Expand Down Expand Up @@ -34,7 +34,7 @@ internal static async Task<IResult> GetUsers(IAdministrationData administrationD
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -62,7 +62,7 @@ internal static async Task<IResult> GetUser(int id, IAdministrationData administ
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ internal static async Task<IResult> CreateUser([FromBody] User user, IValidator<
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -122,7 +122,7 @@ internal static async Task<IResult> UpdateUser([FromBody] User user, IValidator<
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ internal static async Task<IResult> DeleteUser(int id, IAdministrationData admin
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ internal static async Task<IResult> GetRoles(IAdministrationData administrationD
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -206,7 +206,7 @@ internal static async Task<IResult> GetRole(int id, IAdministrationData administ
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -236,7 +236,7 @@ internal static async Task<IResult> CreateRole([FromBody] Role role, IValidator<
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -266,7 +266,7 @@ internal static async Task<IResult> UpdateRole([FromBody] Role role, IValidator<
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -294,7 +294,7 @@ internal static async Task<IResult> DeleteRole(int id, IAdministrationData admin
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -322,7 +322,7 @@ internal static async Task<IResult> GetPermissions(IAdministrationData administr
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -350,7 +350,7 @@ internal static async Task<IResult> GetPermission(int id, IAdministrationData ad
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -380,7 +380,7 @@ internal static async Task<IResult> CreatePermission([FromBody] Permission permi
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -410,7 +410,7 @@ internal static async Task<IResult> UpdatePermission([FromBody] Permission permi
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -438,7 +438,7 @@ internal static async Task<IResult> DeletePermission(int id, IAdministrationData
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -466,7 +466,7 @@ internal static async Task<IResult> GetPermissionChecklistAsync(IAdministrationD
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down Expand Up @@ -494,7 +494,7 @@ internal static async Task<IResult> GetRoleChecklistAsync(IAdministrationData ad
}
catch (AtlasException ex)
{
logService.Log(Core.Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);
logService.Log(Logging.Enums.LogLevel.Error, ex.Message, ex, authorisation?.User);

return Results.StatusCode(StatusCodes.Status500InternalServerError);
}
Expand Down
Loading

0 comments on commit 4f71b61

Please sign in to comment.