serilog.assert
Serilog.Assert and Log.Assert add assertion-style application logging to ILogger. ``` log.Me(); log.PreconditionNotNull(target); var graphemes = new StringInfo(target??""); log.Assert(graphemes.LengthInTextElements > 0); log.Precondition(0 <= guess && guess <= graphemes.LengthInTextElements); log.ExceptionAndThrowIf( graphemes.SubstringByTextElements(guess,1) is "💥", new ApplicationException("bang!")); var remainder = Remove(graphemes,guess); log.DebugIf(remainder.Length == 0,usefulState: "TBC:is this permitted?"); log.If(graphemes.LengthInTextElements > 0, usefulState: (target,guess,graphemes.LengthInTextElements), label: "Remaining after Removal"); log.PreconditionNotNull(target); log.Postcondition(remainder.Length < target.Length); log.Me(remainder); return remainder; ``` ## What is Logged? - All methods log the current method or member name. - Assertions, Pre-, and Post-Conditions log nothing at all if they pass. - Assertions, Pre-, and Post-Conditions log the literal failed expression if they fail. - log.If() logs nothing at all if the condition is false - log.If() logs the literal condition expression if it is true - All methods can log additional information, either auto-labelled or explicitly labelled. ``` log.Me() log.Assert() log.AssertNotNull() log.Precondition() log.PreconditionNotNull() log.Postcondition() log.PostconditionNotNull() log.AssertElseThrow() log.AssertNotNullElseThrow() log.PreconditionElseThrow() log.PreconditionNotNullElseThrow() log.PostconditionElseThrow() log.PostconditionNotNullElseThrow() log.If() log.IfNot() ``` and ``` log.InformationIf() log.VerboseIf() log.DebugIf() log.WarnIf() log.ErrorIf() log.FatalIf() log.InformationIfNot() log.VerboseIfNot() log.DebugIfNot() log.WarnIfNot() log.ErrorIfNot() log.FatalIfNot() log.ExceptionIf() log.ExceptionAndThrowIf() log.Exception() log.ExceptionAndThrow() log.FatalThenThrow() log.FatalExceptionThenExitProcessWithCode() ```
nuget.org
0.3.0-pre1
1 day ago
3
Links
| Registry | nuget.org |
| Source | Repository |
| JSON API | View JSON |
| CodeMeta | codemeta.json |
Package Details
| PURL |
pkg:nuget/serilog.assert
spec |
| License | LGPL-2.1-or-later |
| First Release | 5 days ago |
| Last Synced | 1 day ago |