Class DiagnosticReporter
- Namespace
- Egami
- Assembly
- Egami.dll
One call's link to Diagnostics, with the same level filter and per-id cap Egami's own readers and writers use. Get one from StartDiagnostics() at the start of a call (format plug-ins use Diagnostics) and dispose it when the call ends. When the context has no handler it is a shared instance that does nothing, so reporting costs one check.
public sealed class DiagnosticReporter : IDisposable
- Inheritance
-
DiagnosticReporter
- Implements
- Inherited Members
Examples
// A decoder outside Egami (a video demuxer, a format plug-in's own entry point) reports through the same handler, with the
// same level filter and the same cap of 10 per id per call. Dispose the reporter when the call ends.
using (DiagnosticReporter diagnostics = context.StartDiagnostics())
{
if (diagnostics.IsEnabled(DiagnosticLevel.Warning))
{
diagnostics.Report(DiagnosticLevel.Warning, "Avi.IndexRebuilt", "The index was missing; it was rebuilt from the frames.", offset: 4096);
}
diagnostics.Report(DiagnosticLevel.Info, "Mjpeg.DhtInserted", "Frames have no Huffman tables; the standard ones were used.");
}
Remarks
Each id is delivered at most 10 times per reporter; disposing sends one more event per capped id that counts the rest. Report(DiagnosticLevel, string, string, long?, int?) may be called from several threads at once.
Methods
Dispose()
Ends the call: sends one event for each capped id, counting the events left out.
public void Dispose()
IsEnabled(DiagnosticLevel)
Gets whether events at level are delivered. Check it before building an expensive message.
public bool IsEnabled(DiagnosticLevel level)
Parameters
levelDiagnosticLevelThe level of the event about to be reported.
Returns
Report(DiagnosticLevel, string, string, long?, int?)
Reports an event, unless its level is below the context's or its id has already been delivered 10 times.
public void Report(DiagnosticLevel level, string id, string message, long? offset = null, int? frame = null)
Parameters
levelDiagnosticLevelHow much the event matters.
idstringA stable id of the form
Source.Name, such as"Video.FrameDropped".messagestringWhat happened and what was done, as a sentence.
offsetlong?The byte offset in the input the event is about, if known.
frameint?The frame or page index the event is about, if known.
Exceptions
- ArgumentException
idis not of the formSource.Name, ormessageis empty.
Report(EgamiDiagnostic)
Reports an event built elsewhere, unless its level is below the context's or its id is past the cap.
public void Report(EgamiDiagnostic diagnostic)
Parameters
diagnosticEgamiDiagnosticThe event.
Exceptions
- ArgumentException
The event's id or message is empty.