diff --git a/README.md b/README.md index d26c202..c3ab5bb 100644 --- a/README.md +++ b/README.md @@ -133,4 +133,28 @@ catch (Exception ex) List allInnerExceptionMessagesAndStackTraces = ex.AllInnerExceptionMessagesAndStackTraces(); ... } -``` \ No newline at end of file +``` + +## Logging Extensions + +### DisposableStopWatchExtension + +This extends `ILogger` with a timer that can wrap code with a using statement. It was heavily inspired by James Curran's [blog post](https://honestillusion.com/2021/12/14/Simple-timings.html). With this extension you can quickly, easily and cleanly stick `StopWatch` objects around code that you wish to time. + +```csharp +using (_logger.DisposableStopWatch()) +{ + ... +} +``` + +It takes in additional parameters for a message and whether or not to also write to a Console for quick and dirty iterating. + +```csharp +using (_logger.DisposableStopWatch("A message", true)) +{ + ... +} +``` + +You get a `Start:` log, with the message appended if you've passed it, and once your code within the using block has run you get `Complete:` with the messaged appended if you've passed it, then on the same line `Elapsed:` and the time elapsed in HH:MM:SS:MS..... format.