diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE index 3bb754f..e54280b 100644 --- a/.github/PULL_REQUEST_TEMPLATE +++ b/.github/PULL_REQUEST_TEMPLATE @@ -3,7 +3,7 @@ @@ -23,13 +23,14 @@ This PR addresses Issue #. ### Optional - -- [ ] I have updated the `readme.md` file +- [ ] I have updated the repo `readme.md` file. +- [ ] I have updated the package `readme.md` file. - [ ] I have updated the documentation in the docs folder. -- [ ] I have bumped the version number in the `version.txt` +- [ ] I have bumped the version number in the `version.txt`. - [ ] I have added or updated any necessary tests. -- [ ] I have ensured that any new code is covered by tests where reasonably possible. \ No newline at end of file +- [ ] I have ensured that any new code is covered by tests where reasonably possible. diff --git a/release-notes/wip-release-notes.md b/release-notes/wip-release-notes.md index ce1f912..d1a6bf2 100644 --- a/release-notes/wip-release-notes.md +++ b/release-notes/wip-release-notes.md @@ -23,6 +23,7 @@ Date: ??? ### Miscellaneous +- #36: Add package readme - #164: Update pipeline. - #172: Drop support and package targeting for .NET 7.0. - #179: Update github pages pipeline diff --git a/src/Stravaig.Extensions.Logging.Diagnostics/Stravaig.Extensions.Logging.Diagnostics.csproj b/src/Stravaig.Extensions.Logging.Diagnostics/Stravaig.Extensions.Logging.Diagnostics.csproj index 7c103c1..5ab01eb 100644 --- a/src/Stravaig.Extensions.Logging.Diagnostics/Stravaig.Extensions.Logging.Diagnostics.csproj +++ b/src/Stravaig.Extensions.Logging.Diagnostics/Stravaig.Extensions.Logging.Diagnostics.csproj @@ -12,6 +12,7 @@ stravaig-icon.png logging testing true + readme.md A logging provider that hooks into the .NET Logging extensions and captures the logs that it receives so they can be examined later by tests. @@ -36,6 +37,10 @@ true + + + + diff --git a/src/Stravaig.Extensions.Logging.Diagnostics/readme.md b/src/Stravaig.Extensions.Logging.Diagnostics/readme.md new file mode 100644 index 0000000..9487571 --- /dev/null +++ b/src/Stravaig.Extensions.Logging.Diagnostics/readme.md @@ -0,0 +1,45 @@ +# About + +Stravaig Log Capture is a way to capture the logs in a test and examine them to ensure they are being generated correctly. + +## Version & Framework support + +* v1.x: Supports .NET Core 3.1 & .NET 5 +* v2.x: Supports .NET 6.0, 7.0 & 8.0 +* v3.x: Supports .NET 6.0 & 8.0 + +## Why do I want to test my logs? + +Checking logs in test can be beneficial for a number of reasons. +For example, in a background service the log is effectively its user +interface (the user being the developer or system admin whose job it +is to monitor the correct running of background services). By verifying +the logs in tests, you can ensure that appropriate information is being +delivered. + +Logging may also exist to output audit trails for the application, and you +need to check in tests that it is being produced correctly. + +## How to use + +For simple tests you can pass the logger into the class under test like this: + +```csharp +[Test] +public void EnsureSomeFunctionalityWorks() +{ + // Arrange + var logger = new TestCaptureLogger(); + var service = new ServiceClass(logger); + + // Act + service.DoSomething(); + + // Assert + var logs = logger.GetLogs(); + logs.Count.ShouldBe(1); + logs[0].OriginalMessage.ShouldBe("Did something."); +} +``` + +For more details on more complex scenarios, see the full documentation at https://stravaig-projects.github.io/Stravaig.Extensions.Logging.Diagnostics/