Skip to content

Commit 158c631

Browse files
Add missing XML docs & include XML docs in the NuGet package
1 parent ae6d735 commit 158c631

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/Serilog.Enrichers.GlobalLogContext/Context/GlobalLogContext.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,55 @@
2323

2424
namespace Serilog.Context
2525
{
26+
/// <summary>
27+
/// Holds global properties that can be attached to log events. To
28+
/// configure, use the <see cref="LoggerEnrichmentConfigurationExtensions.FromGlobalLogContext(Configuration.LoggerEnrichmentConfiguration)" /> method.
29+
/// </summary>
30+
/// <example>
31+
/// Configuration:
32+
/// <code lang="C#">
33+
/// Log.Logger = new LoggerConfiguration()
34+
/// .Enrich.FromGlobalLogContext()
35+
/// // ... other configuration ...
36+
/// .CreateLogger();
37+
/// </code>
38+
/// Usage:
39+
/// <code lang="C#">
40+
/// GlobalLogContext.PushProperty("AppVersion", buildInfo.Version);
41+
///
42+
/// Log.Information("The AppVersion property will be attached to this event and all others following");
43+
/// Log.Warning("The AppVersion property will also be attached to this event and all others following");
44+
/// </code>
45+
/// </example>
46+
/// <remarks>
47+
/// The scope of the context is global to the application and is
48+
/// shared between all threads.
49+
/// </remarks>
2650
public static class GlobalLogContext
2751
{
2852
private static readonly SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(1, 1);
2953
private static ImmutableStack<ILogEventEnricher> _data;
3054

55+
/// <summary>
56+
/// Acquires an exclusive lock on the global log context.
57+
/// </summary>
58+
/// <returns>
59+
/// A token that can be disposed, in order to release
60+
/// the exclusive lock on the global log context.
61+
/// </returns>
3162
public static IDisposable Lock()
3263
{
3364
_semaphoreSlim.Wait();
3465
return new ContextLock();
3566
}
3667

68+
/// <summary>
69+
/// Acquires an exclusive lock on the global log context, asynchronously.
70+
/// </summary>
71+
/// <returns>
72+
/// A token that can be disposed, in order to release
73+
/// the exclusive lock on the global log context.
74+
/// </returns>
3775
public static async Task<IDisposable> LockAsync()
3876
{
3977
await _semaphoreSlim.WaitAsync().ConfigureAwait(false);

src/Serilog.Enrichers.GlobalLogContext/LoggerEnrichmentConfigurationExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020

2121
namespace Serilog
2222
{
23+
/// <summary>
24+
/// Extends <see cref="LoggerEnrichmentConfiguration"/> with global enrichment methods.
25+
/// </summary>
2326
public static class LoggerEnrichmentConfigurationExtensions
2427
{
2528
/// <summary>
26-
/// Enrich log events with properties from <see cref="GlobalLogContext"/>.
29+
/// Enrich log events with properties from <see cref="Context.GlobalLogContext"/>.
2730
/// </summary>
2831
/// <returns>Configuration object allowing method chaining.</returns>
2932
/// <exception cref="ArgumentNullException"></exception>

src/Serilog.Enrichers.GlobalLogContext/Serilog.Enrichers.GlobalLogContext.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<AssemblyVersion>1.0.0.0</AssemblyVersion>
99
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
1010
<GenerateAssemblyFileVersionAttribute>true</GenerateAssemblyFileVersionAttribute>
11-
<GenerateDocumentationFile>false</GenerateDocumentationFile>
11+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212

1313
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1414
<DebugType>portable</DebugType>

0 commit comments

Comments
 (0)