Skip to content

Commit b11364e

Browse files
committed
Add XML documentation to extensions.
1 parent e13f798 commit b11364e

File tree

12 files changed

+160
-33
lines changed

12 files changed

+160
-33
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
A simple Serilog log viewer for following sinks:
33
- [Serilog.Sinks.MSSqlServer](https://github.com/serilog/serilog-sinks-mssqlserver)
44
- [Serilog.Sinks.MySql](https://github.com/TeleSoftas/serilog-sinks-mariadb)
5-
- [Serilog.Sinks.Postgresql](https://github.com/b00ted/serilog-sinks-postgresql),
6-
- [Serilog.Sinks.MongoDB](https://github.com/serilog/serilog-sinks-mongodb)
7-
- [Serilog.Sinks.ElasticSearch](https://github.com/serilog/serilog-sinks-elasticsearch)
5+
- [Serilog.Sinks.Postgresql](https://github.com/b00ted/serilog-sinks-postgresql)
6+
- [Serilog.Sinks.MongoDB](https://github.com/serilog/serilog-sinks-mongodb)
7+
- [Serilog.Sinks.ElasticSearch](https://github.com/serilog/serilog-sinks-elasticsearch)
88

99
![serilog ui](https://raw.githubusercontent.com/mo-esmp/serilog-ui/master/assets/serilog-ui.jpg)
1010

src/Serilog.Ui.ElasticSearchProvider/Extensions/SerilogUiOptionBuilderExtensions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@
66

77
namespace Serilog.Ui.ElasticSearchProvider
88
{
9+
/// <summary>
10+
/// ElasticSearch data provider specific extension methods for <see cref="SerilogUiOptionsBuilder"/>.
11+
/// </summary>
912
public static class SerilogUiOptionBuilderExtensions
1013
{
14+
/// <summary>
15+
/// Configures the SerilogUi to connect to a MongoDB database.
16+
/// </summary>
17+
/// <param name="optionsBuilder"> The options builder. </param>
18+
/// <param name="endpoint"> The url of ElasticSearch server. </param>
19+
/// <param name="indexName"> Name of the log index. </param>
20+
/// <exception cref="ArgumentNullException"> throw if endpoint is null </exception>
21+
/// <exception cref="ArgumentNullException"> throw is indexName is null </exception>
1122
public static void UseElasticSearchDb(this SerilogUiOptionsBuilder optionsBuilder, Uri endpoint, string indexName)
1223
{
1324
if (endpoint == null)

src/Serilog.Ui.MongoDbProvider/Extensions/SerilogUiOptionBuilderExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@
55

66
namespace Serilog.Ui.MongoDbProvider
77
{
8+
/// <summary>
9+
/// MongoDB data provider specific extension methods for <see cref="SerilogUiOptionsBuilder"/>.
10+
/// </summary>
811
public static class SerilogUiOptionBuilderExtensions
912
{
13+
/// <summary>
14+
/// Configures the SerilogUi to connect to a MongoDB database.
15+
/// </summary>
16+
/// <param name="optionsBuilder"> The options builder. </param>
17+
/// <param name="connectionString"> The connection string. </param>
18+
/// <param name="databaseName"> Name of the data table. </param>
19+
/// <param name="collectionName"> Name of the collection name. </param>
20+
/// <exception cref="ArgumentNullException"> throw if connectionString is null </exception>
21+
/// <exception cref="ArgumentNullException"> throw is databaseName is null </exception>
22+
/// <exception cref="ArgumentNullException"> throw is collectionName is null </exception>
1023
public static void UseMongoDb(
1124
this SerilogUiOptionsBuilder optionsBuilder,
1225
string connectionString,

src/Serilog.Ui.MsSqlServerProvider/Extensions/SerilogUiOptionBuilderExtensions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44

55
namespace Serilog.Ui.MsSqlServerProvider
66
{
7+
/// <summary>
8+
/// SQL Server data provider specific extension methods for <see cref="SerilogUiOptionsBuilder"/>.
9+
/// </summary>
710
public static class SerilogUiOptionBuilderExtensions
811
{
12+
/// <summary>
13+
/// Configures the SerilogUi to connect to a SQL Server database.
14+
/// </summary>
15+
/// <param name="optionsBuilder"> The options builder. </param>
16+
/// <param name="connectionString"> The connection string. </param>
17+
/// <param name="tableName"> Name of the table. </param>
18+
/// <param name="schemaName">
19+
/// Name of the table schema. default value is <c> dbo </c>
20+
/// </param>
21+
/// <exception cref="ArgumentNullException"> throw if connectionString is null </exception>
22+
/// <exception cref="ArgumentNullException"> throw is tableName is null </exception>
923
public static void UseSqlServer(
1024
this SerilogUiOptionsBuilder optionsBuilder,
1125
string connectionString,

src/Serilog.Ui.MsSqlServerProvider/Serilog.Ui.MsSqlServerProvider.csproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
15-
</ItemGroup>
16-
17-
<ItemGroup>
18-
<Folder Include="Extensions\" />
14+
<PackageReference Include="Dapper" Version="2.0.35" />
15+
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.1" />
1916
</ItemGroup>
2017

2118
<ItemGroup>
22-
<PackageReference Include="Dapper" Version="2.0.35" />
23-
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.1" />
19+
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
2420
</ItemGroup>
2521
</Project>

src/Serilog.Ui.MySqlProvider/Extensions/SerilogUiOptionBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Serilog.Ui.Core;
33
using System;
44

5-
namespace Serilog.Ui.MySqlProvider.Extensions
5+
namespace Serilog.Ui.MySqlProvider
66
{
77
/// <summary>
88
/// MySQL data provider specific extension methods for <see cref="SerilogUiOptionsBuilder"/>.

src/Serilog.Ui.PostgreSqlProvider/Extensions/SerilogUiOptionBuilderExtensions.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
using System;
2-
using Microsoft.Extensions.DependencyInjection;
1+
using Microsoft.Extensions.DependencyInjection;
32
using Serilog.Ui.Core;
3+
using System;
44

5-
namespace Serilog.Ui.PostgreSqlProvider.Extensions
5+
namespace Serilog.Ui.PostgreSqlProvider
66
{
7+
/// <summary>
8+
/// PostgreSQL data provider specific extension methods for <see cref="SerilogUiOptionsBuilder"/>.
9+
/// </summary>
710
public static class SerilogUiOptionBuilderExtensions
811
{
12+
/// <summary>
13+
/// Configures the SerilogUi to connect to a PostgreSQL database.
14+
/// </summary>
15+
/// <param name="optionsBuilder"> The options builder. </param>
16+
/// <param name="connectionString"> The connection string. </param>
17+
/// <param name="tableName"> Name of the table. </param>
18+
/// <param name="schemaName">
19+
/// Name of the table schema. default value is <c> public </c>
20+
/// </param>
21+
/// <exception cref="ArgumentNullException"> throw if connectionString is null </exception>
22+
/// <exception cref="ArgumentNullException"> throw is tableName is null </exception>
923
public static void UseNpgSql(
1024
this SerilogUiOptionsBuilder optionsBuilder,
1125
string connectionString,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using System;
4+
5+
namespace Serilog.Ui.Web
6+
{
7+
/// <summary>
8+
/// Contains extensions for configuring routing on an <see cref="IApplicationBuilder"/>.
9+
/// </summary>
10+
public static class ApplicationBuilderExtensions
11+
{
12+
/// <summary>
13+
/// Adds a <see cref="SerilogUiMiddleware"/> middleware to the specified <see cref="IApplicationBuilder"/>.
14+
/// </summary>
15+
/// <param name="applicationBuilder">
16+
/// The <see cref="IApplicationBuilder"/> to add the middleware to.
17+
/// </param>
18+
/// <param name="options"> The options to configure SerilogUI dashboard. </param>
19+
/// <returns> IApplicationBuilder. </returns>
20+
/// <exception cref="ArgumentNullException"> throw if applicationBuilder if null </exception>
21+
public static IApplicationBuilder UseSerilogUi(this IApplicationBuilder applicationBuilder, Action<UiOptions> options = null)
22+
{
23+
if (applicationBuilder == null)
24+
throw new ArgumentNullException(nameof(applicationBuilder));
25+
26+
var uiOptions = new UiOptions();
27+
options?.Invoke(uiOptions);
28+
29+
var scope = applicationBuilder.ApplicationServices.CreateScope();
30+
var authOptions = scope.ServiceProvider.GetService<AuthorizationOptions>();
31+
uiOptions.AuthType = authOptions.AuthenticationType.ToString();
32+
33+
scope.Dispose();
34+
35+
return applicationBuilder.UseMiddleware<SerilogUiMiddleware>(uiOptions);
36+
}
37+
}
38+
}

src/Serilog.Ui.Web/Extensions/AuthorizationOptions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,33 @@
22

33
namespace Serilog.Ui.Web
44
{
5+
/// <summary>
6+
/// The options to be used by SerilogUI to log access authorization.
7+
/// </summary>
58
public class AuthorizationOptions
69
{
10+
/// <summary>
11+
/// Gets or sets the type of the authentication.
12+
/// </summary>
13+
/// <value> The type of the authentication. </value>
714
public AuthenticationType AuthenticationType { get; set; }
815

16+
/// <summary>
17+
/// Gets or sets the authorized usernames.
18+
/// </summary>
19+
/// <value> The usernames. </value>
920
public IEnumerable<string> Usernames { get; set; }
1021

22+
/// <summary>
23+
/// Gets or sets the authorized roles.
24+
/// </summary>
25+
/// <value> The roles. </value>
1126
public IEnumerable<string> Roles { get; set; }
1227

28+
/// <summary>
29+
/// Gets or sets a value indicating whether this <see cref="AuthorizationOptions"/> is enabled.
30+
/// </summary>
31+
/// <value> <c> true </c> if enabled; otherwise, <c> false </c>. </value>
1332
internal bool Enabled { get; set; } = false;
1433
}
1534

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
using Microsoft.AspNetCore.Builder;
2-
using Microsoft.Extensions.DependencyInjection;
1+
using Microsoft.Extensions.DependencyInjection;
32
using Serilog.Ui.Core;
43
using System;
54

65
namespace Serilog.Ui.Web
76
{
7+
/// <summary>
8+
/// Extension methods for <see cref="SerilogUiOptionsBuilder"/>.
9+
/// </summary>
810
public static class SerilogUiOptionBuilderExtensions
911
{
12+
/// <summary>
13+
/// In order to give appropriate rights for production use, you need to enables
14+
/// configuring authorization. By default only local requests have access to the log
15+
/// dashboard page.
16+
/// </summary>
17+
/// <param name="optionsBuilder"> The builder being used to configure the SerilogUI. </param>
18+
/// <param name="options"> An action to allow configure authorization. </param>
19+
/// <returns> SerilogUiOptionsBuilder. </returns>
20+
/// <exception cref="ArgumentNullException"> Throw if optionsBuilder is null </exception>
21+
/// <exception cref="ArgumentNullException"> Throw if options is null </exception>
1022
public static SerilogUiOptionsBuilder EnableAuthorization(this SerilogUiOptionsBuilder optionsBuilder, Action<AuthorizationOptions> options)
1123
{
1224
if (optionsBuilder == null)
@@ -22,22 +34,5 @@ public static SerilogUiOptionsBuilder EnableAuthorization(this SerilogUiOptionsB
2234

2335
return optionsBuilder;
2436
}
25-
26-
public static IApplicationBuilder UseSerilogUi(this IApplicationBuilder applicationBuilder, Action<UiOptions> options = null)
27-
{
28-
if (applicationBuilder == null)
29-
throw new ArgumentNullException(nameof(applicationBuilder));
30-
31-
var uiOptions = new UiOptions();
32-
options?.Invoke(uiOptions);
33-
34-
var scope = applicationBuilder.ApplicationServices.CreateScope();
35-
var authOptions = scope.ServiceProvider.GetService<AuthorizationOptions>();
36-
uiOptions.AuthType = authOptions.AuthenticationType.ToString();
37-
38-
scope.Dispose();
39-
40-
return applicationBuilder.UseMiddleware<SerilogUiMiddleware>(uiOptions);
41-
}
4237
}
4338
}

src/Serilog.Ui.Web/Extensions/ServiceCollectionExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@
55

66
namespace Serilog.Ui.Web
77
{
8+
/// <summary>
9+
/// Extension methods for setting up SerilogUI related services in an <see cref="IServiceCollection"/>.
10+
/// </summary>
811
public static class ServiceCollectionExtensions
912
{
13+
/// <summary>
14+
/// Registers the SerilogUI as a service in the <see cref="IServiceCollection"/>.
15+
/// </summary>
16+
/// <param name="services"> The services. </param>
17+
/// <param name="optionsBuilder">
18+
/// An action to configure the <see cref="SerilogUiOptionsBuilder"/> for the SerilogUI.
19+
/// </param>
20+
/// <exception cref="ArgumentNullException"> services </exception>
21+
/// <exception cref="ArgumentNullException"> optionsBuilder </exception>
22+
/// <returns> The same service collection so that multiple calls can be chained. </returns>
1023
public static IServiceCollection AddSerilogUi(this IServiceCollection services, Action<SerilogUiOptionsBuilder> optionsBuilder)
1124
{
1225
if (services == null)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
namespace Serilog.Ui.Web
22
{
3+
/// <summary>
4+
/// The options to be used by SerilogUI to configure log dashboard. You normally use a <see
5+
/// cref="Core.SerilogUiOptionsBuilder"/> to create instances of this class.
6+
/// </summary>
37
public class UiOptions
48
{
9+
/// <summary>
10+
/// Gets or sets the route prefix to access log dashboard via browser. The default value
11+
/// is <c> serilog-ui </c> and you can the dashboard by using <c>
12+
/// http://localhost/serilog-ui </c>
13+
/// </summary>
14+
/// <value> The route prefix. </value>
515
public string RoutePrefix { get; set; } = "serilog-ui";
616

17+
/// <summary>
18+
/// Gets or sets the type of the authentication.
19+
/// </summary>
20+
/// <value> The type of the authentication. </value>
721
internal string AuthType { get; set; }
822
}
923
}

0 commit comments

Comments
 (0)