Class LogAssertionRendering
- Namespace
- LogAssertions
- Assembly
- LogAssertions.dll
Shared helpers for rendering captured log records into human-readable text. Used both by
the assertion classes (failure-message snapshot rendering) and by the
FakeLogCollectorInspectionExtensions.DumpTo extension.
public static class LogAssertionRendering
- Inheritance
-
LogAssertionRendering
- Inherited Members
Remarks
The rendering format is documented as not stable; see the README "Stability
promise" section. Tests should not pin exact failure-message text: pin filter
match counts and broad markers (e.g. "[warn]") only.
Methods
AppendCapturedRecords(StringBuilder, IReadOnlyList<FakeLogRecord>)
Appends the captured-records section to sb: one summary line per
record ([lvl] category: message) followed by indented detail lines for any
structured properties, active scopes, and exception (when present). Equivalent to
AppendCapturedRecords(StringBuilder, IReadOnlyList<FakeLogRecord>, DumpVerbosity)
with Default.
public static void AppendCapturedRecords(StringBuilder sb, IReadOnlyList<FakeLogRecord> snapshot)
Parameters
sbStringBuilderThe target string builder.
snapshotIReadOnlyList<FakeLogRecord>All captured records.
Exceptions
- ArgumentNullException
A required argument is null.
AppendCapturedRecords(StringBuilder, IReadOnlyList<FakeLogRecord>, DumpVerbosity)
Verbosity-controlled overload of AppendCapturedRecords(StringBuilder, IReadOnlyList<FakeLogRecord>).
public static void AppendCapturedRecords(StringBuilder sb, IReadOnlyList<FakeLogRecord> snapshot, DumpVerbosity verbosity)
Parameters
sbStringBuilderThe target string builder.
snapshotIReadOnlyList<FakeLogRecord>All captured records.
verbosityDumpVerbosityHow much detail to render per record. See DumpVerbosity for the contract of each level.
Exceptions
- ArgumentNullException
A required argument is null.
LevelAbbreviation(LogLevel)
4-character abbreviation of a log level, matching the conventional
Microsoft.Extensions.Logging console formatter (trce, dbug, info,
warn, fail, crit, none). Anything outside the standard
range falls back to the level's invariant ToString().
public static string LevelAbbreviation(LogLevel level)
Parameters
levelLogLevelThe log level to abbreviate.
Returns
- string
The 4-character abbreviation.