| | | 1 | | //======================================================================= |
| | | 2 | | // DiagnosticEvent.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | namespace Chronicler.Diagnostics; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Represents a single diagnostic event emitted by a <see cref="DiagnosticChannel"/>. |
| | | 12 | | /// </summary> |
| | | 13 | | public readonly struct DiagnosticEvent |
| | | 14 | | { |
| | | 15 | | /// <summary>Creates an immutable diagnostic event.</summary> |
| | | 16 | | /// <param name="channel">The channel label. Null becomes empty.</param> |
| | | 17 | | /// <param name="level">The severity attached to the event.</param> |
| | | 18 | | /// <param name="message">The rendered event text. Null becomes empty.</param> |
| | | 19 | | /// <param name="source">The optional origin label. Null or omission becomes empty.</param> |
| | | 20 | | public DiagnosticEvent( |
| | | 21 | | string channel, |
| | | 22 | | DiagnosticLevel level, |
| | | 23 | | string message, |
| | | 24 | | string source = "") |
| | | 25 | | { |
| | 21 | 26 | | Channel = channel ?? string.Empty; |
| | 21 | 27 | | Level = level; |
| | 21 | 28 | | Message = message ?? string.Empty; |
| | 21 | 29 | | Source = source ?? string.Empty; |
| | 21 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the channel label.</summary> |
| | | 33 | | /// <value>The emitting channel's name.</value> |
| | | 34 | | public string Channel { get; } |
| | | 35 | | |
| | | 36 | | /// <summary>Gets event severity.</summary> |
| | | 37 | | /// <value>The level carried through to sinks and formatters.</value> |
| | | 38 | | public DiagnosticLevel Level { get; } |
| | | 39 | | |
| | | 40 | | /// <summary>Gets the event text.</summary> |
| | | 41 | | /// <value>The caller's formatted message, with null normalized to empty.</value> |
| | | 42 | | public string Message { get; } |
| | | 43 | | |
| | | 44 | | /// <summary>Gets the origin label.</summary> |
| | | 45 | | /// <value>The supplied origin or an empty string.</value> |
| | | 46 | | public string Source { get; } |
| | | 47 | | } |