Skip to content

Commit 2b78a93

Browse files
#140: Add docs for LogLevel
1 parent 42d75ee commit 2b78a93

File tree

6 files changed

+92
-6
lines changed

6 files changed

+92
-6
lines changed

docs/_config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ kramdown:
1818
github:
1919
repository_url: https://github.com/Stravaig-Projects/Stravaig.Extensions.Logging.Diagnostics
2020

21-
# UPDATE ME IN A NEW REPOSITORY
2221
nuget:
2322
urls:
2423
- https://www.nuget.org/packages/Stravaig.Extensions.Logging.Diagnostics
2524
- https://www.nuget.org/packages/Stravaig.Extensions.Logging.Diagnostics.XUnit
26-
# - https://www.nuget.org/packages/Stravaig.Package3.etc
25+
- https://www.nuget.org/packages/Stravaig.Extensions.Logging.Diagnostics.Verify

docs/docs/library/verify-extensions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ Nondeterministic values in the verified file produce brittle tests, so the parts
6767
## How do I set up to verify the things I want?
6868

6969
* Configure the [Sequence](verify/sequence.md)
70+
* Verify the [LogLevel](verify/loglevel.md)
7071

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
layout: default
3+
title: Verify Logs - Sequence
4+
---
5+
6+
# Verifying the log level of log entries
7+
8+
The `LoggingCaptureVerifySettings` has a Boolean `LogLevel` property that defines if the log level is to be verified or not.
9+
10+
```csharp
11+
public async Task VerifyWarningLogsAreEmittedCorrectlyTestAsync()
12+
{
13+
// ... Code that produces logs
14+
15+
VerifySettings verifySettings = new VerifySettings()
16+
.AddCapturedLogs(new LoggingCaptureVerifySettings()
17+
{
18+
LogLevel = true,
19+
});
20+
21+
await Verifier.Verify(logs, verifySettings);
22+
}
23+
```
24+
25+
## Example output
26+
27+
### LogLevel = false
28+
29+
```
30+
[
31+
{
32+
Sequence: 0,
33+
CategoryName: Stravaig.LoggingExample.Program,
34+
MessageTemplate: This is the first default log message.
35+
},
36+
{
37+
Sequence: 1,
38+
CategoryName: Stravaig.LoggingExample.Program,
39+
MessageTemplate: This is a warning.
40+
},
41+
{
42+
Sequence: 2,
43+
CategoryName: Stravaig.LoggingExample.Program,
44+
MessageTemplate: An unexpected error occurred.,
45+
Exception: {
46+
Type: System.ApplicationException
47+
}
48+
},
49+
]
50+
```
51+
52+
### LogLevel = true
53+
54+
```
55+
[
56+
{
57+
Sequence: 0,
58+
LogLevel: Information,
59+
CategoryName: Stravaig.LoggingExample.Program,
60+
MessageTemplate: This is the first default log message.
61+
},
62+
{
63+
Sequence: 1,
64+
LogLevel: Warning,
65+
CategoryName: Stravaig.LoggingExample.Program,
66+
MessageTemplate: This is a warning.
67+
},
68+
{
69+
Sequence: 2,
70+
LogLevel: Error,
71+
CategoryName: Stravaig.LoggingExample.Program,
72+
MessageTemplate: An unexpected error occurred.,
73+
Exception: {
74+
Type: System.ApplicationException
75+
}
76+
},
77+
]
78+
```

docs/docs/library/verify/sequence.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ public async Task VerifyWarningLogsAreEmittedCorrectlyTestAsync()
2525
}
2626
```
2727

28+
## When is this useful?
29+
30+
`ShowAsConsecutive` is useful if you want to verify logs in a custom order, but still want to verify which sequence they were originally in.
31+
32+
`ShowAsCadence` is useful if you are only interested in verifying certain logs (e.g. Warnings and above), and want to show that there were some skipped logs in between those you are verifying. However, this may intruduce some brittleness to the verify process as it is easy to insert or remove logs that you may not wish to test for when diagnosing bugs or tidying up the application.
33+
34+
`Hide` is useful if you want to reduce the size of the verify files and you have the logs directly from one of the various `Get...Logs()` methods on the `TestCaptureLoggerProvider` or `TestCaptureLogger`, as they return the logs in the sequence in which they were logged.
35+
2836
## Example output
2937

3038
Here are some examples of the verify output for difference `Sequence` settings.

docs/scripts/contributors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
This is a list of all the contributors to this repository in ascending order by the contributor name.
44

5-
**Colin Mackay** contributed 350 commits from Saturday, 26 September, 2020 @ 20:26:19 +00:00 to Sunday, 17 March, 2024 @ 22:16:23 +00:00.
5+
**Colin Mackay** contributed 352 commits from Saturday, 26 September, 2020 @ 20:26:19 +00:00 to Wednesday, 20 March, 2024 @ 22:53:33 +00:00.
66

77
**dependabot[bot]** contributed 59 commits from Wednesday, 14 October, 2020 @ 19:13:43 +00:00 to Monday, 26 February, 2024 @ 14:54:09 +00:00.
88

99
**StravaigBot** contributed 28 commits from Monday, 14 December, 2020 @ 19:28:09 +00:00 to Tuesday, 27 February, 2024 @ 21:50:14 +00:00.
1010

1111
## Summary
1212

13-
:octocat: 437 commits in total.
13+
:octocat: 439 commits in total.
1414

1515
:date: From Saturday, 26 September, 2020 @ 20:26:19 +00:00.
1616

17-
:date: Until Sunday, 17 March, 2024 @ 22:16:23 +00:00.
17+
:date: Until Wednesday, 20 March, 2024 @ 22:53:33 +00:00.
1818

src/Stravaig.Extensions.Logging.Diagnostics.Verify/LoggingCaptureVerifySettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class LoggingCaptureVerifySettings
3636
public Sequence Sequence { get; init; } = Sequence.ShowAsConsecutive;
3737

3838
/// <summary>
39-
/// Gets whether the log leve is to be verified.
39+
/// Gets whether the log level is to be verified.
4040
/// Default is true.
4141
/// </summary>
4242
public bool LogLevel { get; init; } = true;

0 commit comments

Comments
 (0)