Skip to content

Commit

Permalink
Pre-release of v1.1.0 alpha BREAKING CHANGES
Browse files Browse the repository at this point in the history
Code cleanup, commenting, bug fixes, removal of files
  • Loading branch information
Danny Logsdon committed Aug 14, 2024
1 parent fa97167 commit 202a930
Show file tree
Hide file tree
Showing 160 changed files with 2,412 additions and 2,023 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ None
// WebRequestMessageMiddleware options
"WebRequestMessage": {
"EnableLogging": true,
"EnableLocalIpRequests": true,
"EnableRequestIPAddress": true,
"EnableRequestBody": false,
"EnableRequestBodyOnError": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.7</Version>
<Description>ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more.</Description>
<AssemblyTitle>ServiceBricks.Logging.AzureDataTables</AssemblyTitle>
<Authors>holomodular</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>disable</Nullable>
<Copyright>Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more.</Copyright>
<PackageProjectUrl>http://ServiceBricks.com</PackageProjectUrl>
<PackageIcon>logo.png</PackageIcon>
<PackageTags>service;bricks;logging;azure;azuredatatables</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>ServiceBricks.Logging.AzureDataTables.snk</AssemblyOriginatorKeyFile>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/holomodular/ServiceBricks</RepositoryUrl>
<IsPackable>False</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
Expand Down
67 changes: 55 additions & 12 deletions src/V1/ServiceBricks.Logging.AzureDataTables/Domain/LogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,63 @@
namespace ServiceBricks.Logging.AzureDataTables
{
/// <summary>
/// This is an application log message.
/// LogMessage domain object.
/// </summary>
public class LogMessage : AzureDataTablesDomainObject<LogMessage>, IDpCreateDate
public partial class LogMessage : AzureDataTablesDomainObject<LogMessage>, IDpCreateDate
{
/// <summary>
/// Internal Primary Key.
/// </summary>
public Guid Key { get; set; }
public virtual DateTimeOffset CreateDate { get; set; }
public virtual string Application { get; set; }
public virtual string Server { get; set; }
public virtual string Category { get; set; }
public virtual string UserStorageKey { get; set; }
public virtual string Path { get; set; }
public virtual string Level { get; set; }
public virtual string Message { get; set; }
public virtual string Exception { get; set; }
public virtual string Properties { get; set; }

/// <summary>
/// The date and time the log message was created in UTC.
/// </summary>
public DateTimeOffset CreateDate { get; set; }

/// <summary>
/// The name of the application that created the log message.
/// </summary>
public string Application { get; set; }

/// <summary>
/// The name of the server that created the log message.
/// </summary>
public string Server { get; set; }

/// <summary>
/// The category name that the log message belongs to.
/// </summary>
public string Category { get; set; }

/// <summary>
/// The user storage key associated to the log message.
/// </summary>
public string UserStorageKey { get; set; }

/// <summary>
/// The URI path of the request of the log message.
/// </summary>
public string Path { get; set; }

/// <summary>
/// The severity level of the the log message.
/// </summary>
public string Level { get; set; }

/// <summary>
/// The message of the log message.
/// </summary>
public string Message { get; set; }

/// <summary>
/// The exception message, if any.
/// </summary>
public string Exception { get; set; }

/// <summary>
/// Additional properties of the log message.
/// </summary>
public string Properties { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,146 @@ namespace ServiceBricks.Logging.AzureDataTables
/// <summary>
/// This is an application log message.
/// </summary>
public class WebRequestMessage : AzureDataTablesDomainObject<WebRequestMessage>, IDpCreateDate
public partial class WebRequestMessage : AzureDataTablesDomainObject<WebRequestMessage>, IDpCreateDate
{
/// <summary>
/// Internal Primary Key.
/// </summary>
public Guid Key { get; set; }

/// <summary>
/// The date and time the message was created in UTC.
/// </summary>
public DateTimeOffset CreateDate { get; set; }

/// <summary>
/// The Request IP Address.
/// </summary>
public string RequestIPAddress { get; set; }

/// <summary>
/// The Request Protocol.
/// </summary>
public string RequestProtocol { get; set; }

/// <summary>
/// The Request Scheme.
/// </summary>
public string RequestScheme { get; set; }

/// <summary>
/// The Request Method.
/// </summary>
public string RequestMethod { get; set; }

/// <summary>
/// The Request Body.
/// </summary>
public string RequestBody { get; set; }

/// <summary>
/// The Request Path.
/// </summary>
public string RequestPath { get; set; }

/// <summary>
/// The Request Path Base.
/// </summary>
public string RequestPathBase { get; set; }

/// <summary>
/// The Request Query String.
/// </summary>
public string RequestQueryString { get; set; }

/// <summary>
/// The Request Query.
/// </summary>
public string RequestQuery { get; set; }

/// <summary>
/// The Request Route Values.
/// </summary>
public string RequestRouteValues { get; set; }

/// <summary>
/// The Request Host.
/// </summary>
public string RequestHost { get; set; }

/// <summary>
/// Determine if the Request Content Type is Form.
/// </summary>
public bool? RequestHasFormContentType { get; set; }

/// <summary>
/// The Request Cookies.
/// </summary>
public string RequestCookies { get; set; }

/// <summary>
/// The Request Content Type.
/// </summary>
public string RequestContentType { get; set; }

/// <summary>
/// The Request Content Length.
/// </summary>
public long? RequestContentLength { get; set; }

/// <summary>
/// The Request Headers.
/// </summary>
public string RequestHeaders { get; set; }

/// <summary>
/// Determine if the Request Is Https.
/// </summary>
public bool? RequestIsHttps { get; set; }
public Guid? RequestUserId { get; set; }

/// <summary>
/// The User storage key associated with the Request.
/// </summary>
public string RequestUserStorageKey { get; set; }

/// <summary>
/// The status code of the response.
/// </summary>
public int? ResponseStatusCode { get; set; }

/// <summary>
/// The Response Headers.
/// </summary>
public string ResponseHeaders { get; set; }

/// <summary>
/// The Response Cookies.
/// </summary>
public string ResponseCookies { get; set; }

/// <summary>
/// The Response Content Type.
/// </summary>
public string ResponseContentType { get; set; }

/// <summary>
/// The Response Content Length.
/// </summary>
public long? ResponseContentLength { get; set; }

/// <summary>
/// The Response Total Milliseconds.
/// </summary>
public long? ResponseTotalMilliseconds { get; set; }

/// <summary>
/// The Response Body.
/// </summary>
public string ResponseBody { get; set; }

/// <summary>
/// The exception that occured.
/// </summary>
public string Exception { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,42 @@
namespace ServiceBricks.Logging.AzureDataTables
{
/// <summary>
/// IApplicationBuilder extensions for the Log Module.
/// Extensions for starting the ServiceBricks Logging Azure Data Tables module.
/// </summary>
public static partial class ApplicationBuilderExtensions
{
/// <summary>
/// Flag to indicate if the module has started.
/// </summary>
public static bool ModuleStarted = false;

/// <summary>
/// Start the ServiceBricks Logging Azure Data Tables module.
/// </summary>
/// <param name="applicationBuilder"></param>
/// <returns></returns>
public static IApplicationBuilder StartServiceBricksLoggingAzureDataTables(this IApplicationBuilder applicationBuilder)
{
using (var serviceScope = applicationBuilder.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
var configuration = serviceScope.ServiceProvider.GetRequiredService<IConfiguration>();
var connectionString = configuration.GetAzureDataTablesConnectionString(
LoggingAzureDataTablesConstants.APPSETTING_CONNECTION_STRING);
// AI: Get the connection string
var configuration = applicationBuilder.ApplicationServices.GetRequiredService<IConfiguration>();
var connectionString = configuration.GetAzureDataTablesConnectionString(
LoggingAzureDataTablesConstants.APPSETTING_CONNECTION_STRING);

// Create each table if not exists
TableClient tableClient = new TableClient(
connectionString,
LoggingAzureDataTablesConstants.GetTableName(nameof(LogMessage)));
tableClient.CreateIfNotExists();
// AI: Create each table in the module
TableClient tableClient = new TableClient(
connectionString,
LoggingAzureDataTablesConstants.GetTableName(nameof(LogMessage)));
tableClient.CreateIfNotExists();

tableClient = new TableClient(
connectionString,
LoggingAzureDataTablesConstants.GetTableName(nameof(WebRequestMessage)));
tableClient.CreateIfNotExists();
}
tableClient = new TableClient(
connectionString,
LoggingAzureDataTablesConstants.GetTableName(nameof(WebRequestMessage)));
tableClient.CreateIfNotExists();

// AI: Set the module started flag
ModuleStarted = true;

// Start Logging Core
// AI: Start parent module
applicationBuilder.StartServiceBricksLogging();

return applicationBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,38 @@
namespace ServiceBricks.Logging.AzureDataTables
{
/// <summary>
/// IServiceCollection extensions for the Log module.
/// Extensions to add the ServiceBricks Logging Azure Data Tables module to the service collection.
/// </summary>
public static class ServiceCollectionExtensions
public static partial class ServiceCollectionExtensions
{
/// <summary>
/// Add the ServiceBricks Logging Azure Data Tables module to the service collection.
/// </summary>
/// <param name="services"></param>
/// <param name="configuration"></param>
/// <returns></returns>
public static IServiceCollection AddServiceBricksLoggingAzureDataTables(this IServiceCollection services, IConfiguration configuration)
{
// Add to module registry for automapper
// AI: Add the module to the ModuleRegistry
ModuleRegistry.Instance.RegisterItem(typeof(LoggingAzureDataTablesModule), new LoggingAzureDataTablesModule());

// Add Logging Core
// AI: Add parent module
services.AddServiceBricksLogging(configuration);

// Storage Services
// AI: Configure all options for the module

// AI: Add storage services for the module. Each domain object should have its own storage repository
services.AddScoped<IStorageRepository<LogMessage>, LoggingStorageRepository<LogMessage>>();
services.AddScoped<IStorageRepository<WebRequestMessage>, LoggingStorageRepository<WebRequestMessage>>();

// API Services
// AI: Add API services for the module. Each DTO should have two registrations, one for the generic IApiService<> and one for the named interface
services.AddScoped<IApiService<LogMessageDto>, LogMessageApiService>();
services.AddScoped<ILogMessageApiService, LogMessageApiService>();

services.AddScoped<IApiService<WebRequestMessageDto>, WebRequestMessageApiService>();
services.AddScoped<IWebRequestMessageApiService, WebRequestMessageApiService>();

// Register Business rules
// AI: Register business rules for the module
DomainCreateDateRule<LogMessage>.RegisterRule(BusinessRuleRegistry.Instance);
LogMessageCreateRule.RegisterRule(BusinessRuleRegistry.Instance);
LogMessageQueryRule.RegisterRule(BusinessRuleRegistry.Instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
namespace ServiceBricks.Logging.AzureDataTables
{
/// <summary>
/// This is an automapper profile for the LogMessage domain object.
/// This is a mapping profile for the LogMessage domain object.
/// </summary>
public class LogMessageMappingProfile : Profile
public partial class LogMessageMappingProfile : Profile
{
/// <summary>
/// Constructor
/// </summary>
public LogMessageMappingProfile()
{
// AI: Create a mapping profile for LogMessageDto and LogMessage.
CreateMap<LogMessageDto, LogMessage>()
.ForMember(x => x.CreateDate, y => y.Ignore())
.ForMember(x => x.PartitionKey, y => y.MapFrom<PartitionKeyResolver>())
Expand Down
Loading

0 comments on commit 202a930

Please sign in to comment.