Skip to content

Commit

Permalink
chore: release serilog-ui 2.6.0 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
followynne authored Jan 29, 2024
1 parent 86af828 commit 8eb0e8d
Show file tree
Hide file tree
Showing 26 changed files with 367 additions and 239 deletions.
1 change: 1 addition & 0 deletions samples/SampleWebApp/SampleWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.Ui.MsSqlServerProvider\Serilog.Ui.MsSqlServerProvider.csproj"/>
<ProjectReference Include="..\..\src\Serilog.Ui.Web\Serilog.Ui.Web.csproj"/>
<ProjectReference Include="..\..\src\Serilog.Ui.Core\Serilog.Ui.Core.csproj"/>
</ItemGroup>

</Project>
37 changes: 25 additions & 12 deletions src/Serilog.Ui.Core/AggregateDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ardalis.GuardClauses;

namespace Serilog.Ui.Core
{
/// <summary>
/// Aggregates multiple <see cref="IDataProvider"/> into one instance.
/// Aggregates multiple <see cref="IDataProvider"/> into one instance.
/// </summary>
public class AggregateDataProvider : IDataProvider
{
private IDataProvider _selectedDataProvider;
private readonly Dictionary<string, IDataProvider> _dataProviders = new Dictionary<string, IDataProvider>();
private readonly Dictionary<string, IDataProvider> _dataProviders = new();

/// <summary>
/// It creates an instance of <see cref="AggregateDataProvider"/>.
/// </summary>
/// <param name="dataProviders">IEnumerable of providers.</param>
/// <exception cref="ArgumentNullException">when <paramref name="dataProviders"/> is null</exception>
/// <exception cref="ArgumentException">when <paramref name="dataProviders"/> is empty</exception>
public AggregateDataProvider(IEnumerable<IDataProvider> dataProviders)
{
if (dataProviders == null)
throw new ArgumentNullException(nameof(dataProviders));
Guard.Against.NullOrEmpty(dataProviders, nameof(dataProviders));

foreach (var grouped in dataProviders.GroupBy(dp => dp.Name, p => p, (k, e) => e.ToList()))
{
Expand All @@ -39,25 +44,33 @@ public AggregateDataProvider(IEnumerable<IDataProvider> dataProviders)
}
}

_selectedDataProvider = _dataProviders.First(c => true).Value;
SelectedDataProvider = _dataProviders.First().Value;
}

/// <summary>
/// <inheritdoc cref="IDataProvider.Name"/> NOTE We assume only one Aggregate provider, so
/// the name is static.
/// <inheritdoc cref="IDataProvider.Name"/>
/// NOTE: We assume only one Aggregate provider, so the name is static.
/// </summary>
public string Name => nameof(AggregateDataProvider);

/// <summary>
/// If there is only one data provider, this is it. If there are multiple, this is the
/// current data provider.
/// If there is only one data provider, this is it.
/// If there are multiple, this is the current data provider.
/// </summary>
public IDataProvider SelectedDataProvider => _selectedDataProvider;
private IDataProvider SelectedDataProvider { get; set; }

public void SwitchToProvider(string key) => _selectedDataProvider = _dataProviders[key];
/// <summary>
/// Switch active data provider by key.
/// </summary>
/// <param name="key">Data provider key</param>
public void SwitchToProvider(string key) => SelectedDataProvider = _dataProviders[key];

/// <summary>
/// Existing data providers keys.
/// </summary>
public IEnumerable<string> Keys => _dataProviders.Keys;

/// <inheritdoc/>
public Task<(IEnumerable<LogModel>, int)> FetchDataAsync(
int page,
int count,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
namespace Serilog.Ui.Core
{
/// <summary>
/// Relational Db Options extensions.
/// </summary>
public static class RelationalDbOptionsExtensions
{
/// <summary>
/// Generates a complete data provider name, by using its properties.
/// </summary>
/// <param name="options"><see cref="RelationalDbOptions"/></param>
/// <param name="providerName">Data provider name.</param>
/// <returns></returns>
public static string ToDataProviderName(this RelationalDbOptions options, string providerName)
=> string.Join(".", providerName, options.Schema, options.TableName);
}
Expand Down
24 changes: 24 additions & 0 deletions src/Serilog.Ui.Core/Models/LogModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,44 @@

namespace Serilog.Ui.Core
{
/// <summary>
/// Log Model class.
/// </summary>
public class LogModel
{
/// <summary>
/// It gets or sets RowNo.
/// </summary>
public virtual int RowNo { get; set; }

/// <summary>
/// It gets or sets Level.
/// </summary>
public virtual string Level { get; set; }

/// <summary>
/// It gets or sets Message.
/// </summary>
public virtual string Message { get; set; }

/// <summary>
/// It gets or sets Timestamp.
/// </summary>
public virtual DateTime Timestamp { get; set; }

/// <summary>
/// It gets or sets Exception.
/// </summary>
public virtual string Exception { get; set; }

/// <summary>
/// It gets or sets Properties.
/// </summary>
public virtual string Properties { get; set; }

/// <summary>
/// It gets or sets PropertyType.
/// </summary>
public virtual string PropertyType { get; set; }
}
}
12 changes: 12 additions & 0 deletions src/Serilog.Ui.Core/OptionsBuilder/RelationalDbOptions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
namespace Serilog.Ui.Core
{
/// <summary>
/// RelationDbOptions class
/// </summary>
public class RelationalDbOptions
{
/// <summary>
/// It gets or sets ConnectionString.
/// </summary>
public string ConnectionString { get; set; }

/// <summary>
/// It gets or sets TableName.
/// </summary>
public string TableName { get; set; }

/// <summary>
/// It gets or sets Schema.
/// </summary>
public string Schema { get; set; }
}
}
8 changes: 8 additions & 0 deletions src/Serilog.Ui.Core/OptionsBuilder/SerilogUiOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

namespace Serilog.Ui.Core
{
/// <summary>
/// SerilogUi OptionsBuilder class, used during app services registration.
/// Implements <see cref="ISerilogUiOptionsBuilder"/>.
/// </summary>
public class SerilogUiOptionsBuilder : ISerilogUiOptionsBuilder
{
private readonly IServiceCollection _services;

/// <summary>
/// It creates an instance of <see cref="SerilogUiOptionsBuilder"/>.
/// </summary>
/// <param name="services">Service collection.</param>
public SerilogUiOptionsBuilder(IServiceCollection services)
{
_services = services;
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Ui.Core/Serilog.Ui.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<LangVersion>latest</LangVersion>
<Version>2.5.0</Version>
<Version>2.6.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" PrivateAssets="all" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" PrivateAssets="all" />
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions src/Serilog.Ui.MsSqlServerProvider/package-lock.json

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

6 changes: 3 additions & 3 deletions src/Serilog.Ui.MySqlProvider/Serilog.Ui.MySqlProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Version>2.2.1</Version>
<LangVersion>latest</LangVersion>
<Version>2.2.1</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -12,6 +12,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" PrivateAssets="all" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

namespace Serilog.Ui.PostgreSqlProvider;

/// <inheritdoc/> - Postgres implementation
public class PostgreSqlDbOptions : RelationalDbOptions
{
/// <summary>
/// It gets or sets SinkType.
/// </summary>
public PostgreSqlSinkType SinkType { get; set; }
}
13 changes: 11 additions & 2 deletions src/Serilog.Ui.PostgreSqlProvider/Extensions/PostgreSqlSinkType.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
namespace Serilog.Ui.PostgreSqlProvider;
// ReSharper disable InconsistentNaming
namespace Serilog.Ui.PostgreSqlProvider;

/// <summary>
/// Available Postgres sink types.
/// </summary>
public enum PostgreSqlSinkType
{
/// <remarks>
/// <a href="https://github.com/b00ted/serilog-sinks-postgresql">Sink</a>
/// </remarks>
SerilogSinksPostgreSQL,

/// <remarks>
/// <a href="https://github.com/serilog-contrib/Serilog.Sinks.Postgresql.Alternative">Sink</a>
/// </remarks>
SerilogSinksPostgreSQLAlternative
}
3 changes: 3 additions & 0 deletions src/Serilog.Ui.PostgreSqlProvider/PostgreDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

namespace Serilog.Ui.PostgreSqlProvider;

/// <inheritdoc/>
public class PostgresDataProvider(PostgreSqlDbOptions options) : IDataProvider
{
/// <inheritdoc/>
public string Name => options.ToDataProviderName("NPGSQL");

/// <inheritdoc/>
public async Task<(IEnumerable<LogModel>, int)> FetchDataAsync(
int page,
int count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" PrivateAssets="all" />
<InternalsVisibleTo Include="Postgres.Tests" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Serilog.Ui.Web/Endpoints/SerilogUiEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static (int currPage, int count, string dbKey, string level, string text
/// <returns></returns>
private Task OnError(HttpContext httpContext, Exception ex)
{
_logger.LogError(ex, "@Message", ex.Message);
_logger.LogError(ex, "{Message}", ex.Message);

httpContext.Response.StatusCode = (int) HttpStatusCode.InternalServerError;
httpContext.Response.ContentType = "application/problem+json";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static IServiceCollection AddSerilogUi(this IServiceCollection services,
services.AddScoped<ISerilogUiAppRoutes, SerilogUiAppRoutes>();
services.Decorate<ISerilogUiAppRoutes, SerilogUiAppRoutesDecorator>();

services.TryAddScoped(typeof(AggregateDataProvider));
services.TryAddScoped<AggregateDataProvider>();

return services;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Serilog.Ui.Web/Serilog.Ui.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageId>Serilog.UI</PackageId>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Version>2.5.1</Version>
<Version>2.6.0</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" PrivateAssets="all"/>
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 8eb0e8d

Please sign in to comment.