From 58748ccdd9f408797cde3b0cc4d3622c6324050c Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 13 Sep 2019 16:12:21 -0700 Subject: [PATCH] Follow up on EventSourceListener review comments (#7611) --- .../Diagnostics/AzureEventSourceListener.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sdk/core/Azure.Core/src/Diagnostics/AzureEventSourceListener.cs b/sdk/core/Azure.Core/src/Diagnostics/AzureEventSourceListener.cs index 89c15d616963f..13aacb2d3f225 100644 --- a/sdk/core/Azure.Core/src/Diagnostics/AzureEventSourceListener.cs +++ b/sdk/core/Azure.Core/src/Diagnostics/AzureEventSourceListener.cs @@ -10,6 +10,9 @@ namespace Azure.Core.Diagnostics { + /// + /// Implementation of that listens to events produces by Azure SDK Client libraries + /// public class AzureEventSourceListener: EventListener { public const string TraitName = "AzureEventSource"; @@ -20,9 +23,15 @@ public class AzureEventSourceListener: EventListener private readonly Action _log; private readonly EventLevel _level; + /// + /// Creates an instance of that executes a callback every time event is written. + /// + /// The to call when event is written. The second parameter is formatted message. + /// The level of events to enable. public AzureEventSourceListener(Action log, EventLevel level) { - _log = log; + _log = log ?? throw new ArgumentNullException(nameof(log)); + _level = level; foreach (EventSource eventSource in _eventSources) @@ -53,11 +62,19 @@ protected sealed override void OnEventWritten(EventWrittenEventArgs eventData) _log(eventData, EventSourceEventFormatting.Format(eventData)); } + /// + /// Creates a new instance of that forwards events to + /// + /// The level of events to enable. public static AzureEventSourceListener CreateConsoleLogger(EventLevel level = EventLevel.Informational) { return new AzureEventSourceListener((eventData, text) => Console.WriteLine("[{1}] {0}: {2}", eventData.EventSource.Name, eventData.Level, text), level); } + /// + /// Creates a new instance of that forwards events to + /// + /// The level of events to enable. public static AzureEventSourceListener CreateTraceLogger(EventLevel level = EventLevel.Informational) { return new AzureEventSourceListener(