public ConsoleEventListener( Events eventSource, DateTime baseTime, bool colorize, bool animateTaskbar, bool updatingConsole, bool useCustomPipDescription, bool notWorker = true, WarningMapper warningMapper = null, EventLevel level = EventLevel.Verbose, EventMask eventMask = null, DisabledDueToDiskWriteFailureEventHandler onDisabledDueToDiskWriteFailure = null, PathTranslator pathTranslator = null, int maxStatusPips = DefaultMaxStatusPips) : this( eventSource, new StandardConsole(colorize, animateTaskbar, updatingConsole, pathTranslator), baseTime, useCustomPipDescription, notWorker : notWorker, warningMapper : warningMapper, level : level, eventMask : eventMask, onDisabledDueToDiskWriteFailure : onDisabledDueToDiskWriteFailure, maxStatusPips : maxStatusPips) { }
/// <summary> /// Creates a new instance configured to output to the given writer. /// </summary> /// <param name="eventSource"> /// The event source to listen to. /// </param> /// <param name="writer">The TextWriter where to send the output. Note that the writer will be disposed when the TextWriterEventListener is itself disposed.</param> /// <param name="baseTime"> /// The UTC time representing time 0 for this listener. /// </param> /// <param name="warningMapper"> /// An optional delegate that is used to map warnings into errors or to suppress warnings. /// </param> /// <param name="level"> /// The base level of data to be sent to the listener. /// </param> /// <param name="timeDisplay"> /// The kind of time prefix to apply to each chunk of output. /// </param> /// <param name="eventMask"> /// If specified, an EventMask that allows selectively enabling or disabling events /// </param> /// <param name="onDisabledDueToDiskWriteFailure"> /// If specified, called if the listener encounters a disk-write failure such as an out of space condition. /// Otherwise, such conditions will throw an exception. /// </param> /// <param name="pathTranslator"> /// If specified, translates paths from one root to another /// </param> /// <param name="listenDiagnosticMessages"> /// If true, all messages tagged with <see cref="Keywords.Diagnostics" /> at or above <paramref name="level"/> are enabled but not captured unless diagnostics are enabled per-task. /// This is useful for StatisticsEventListener, where you need to listen diagnostics messages but capture only ones tagged with CommonInfrastructure task. /// </param> public TextWriterEventListener( Events eventSource, IEventWriter writer, DateTime baseTime, WarningMapper warningMapper = null, EventLevel level = EventLevel.Verbose, TimeDisplay timeDisplay = TimeDisplay.None, EventMask eventMask = null, DisabledDueToDiskWriteFailureEventHandler onDisabledDueToDiskWriteFailure = null, PathTranslator pathTranslator = null, bool listenDiagnosticMessages = false) : base( eventSource, baseTime, warningMapper, level, false, timeDisplay, eventMask, onDisabledDueToDiskWriteFailure, listenDiagnosticMessages) { Contract.Requires(eventSource != null); Contract.Requires(writer != null); m_writer = writer; m_flushTimer = new StoppableTimer( SynchronizedFlush, (int)s_flushInterval.TotalMilliseconds, (int)s_flushInterval.TotalMilliseconds); m_translator = pathTranslator; }
/// <summary> /// Creates a new instance configured to output to the given writer. /// </summary> /// <param name="eventSource"> /// The event source to listen to. /// </param> /// <param name="writer">The TextWriter where to send the output.</param> /// <param name="baseTime">The UTC time when the build started.</param> /// <param name="warningMapper"> /// An optional delegate that is used to map warnings into errors or to suppress warnings. /// </param> /// <param name="logErrors"> /// When true, will log errors. /// </param> /// <param name="logWarnings"> /// When true, will log warnings. /// </param> /// <param name="pathTranslator"> /// If specified, translates paths from one root to another /// </param> /// <param name="timeDisplay"> /// The kind of time prefix to apply to each chunk of output. /// </param> public ErrorAndWarningEventListener( Events eventSource, TextWriter writer, DateTime baseTime, bool logErrors, bool logWarnings, WarningMapper warningMapper = null, PathTranslator pathTranslator = null, TimeDisplay timeDisplay = TimeDisplay.None) : base( eventSource, writer, baseTime, warningMapper, logWarnings ? EventLevel.Warning : // The error listener must listen to both warnings and errors, since warnings can be promoted // to errors. When that happens, they need to trigger the error event listener to ensure // they get logged in the error log file (EventLevel.Error | EventLevel.Warning), pathTranslator: pathTranslator, timeDisplay: timeDisplay) { Contract.Requires(eventSource != null); Contract.Requires(writer != null); m_logErrors = logErrors; m_logWarnings = logWarnings; }
/// <summary> /// Creates a new instance with optional colorization. /// </summary> /// <param name="eventSource"> /// The event source to listen to. /// </param> /// <param name="console"> /// Console into which to write messages. /// </param> /// <param name="baseTime"> /// The UTC time representing time 0 for this listener. /// </param> /// <param name="logsDirectory"> /// The absolute path to the logs directory /// </param> /// <param name="notWorker"> /// If this is not a worker. /// </param> /// <param name="warningMapper"> /// An optional delegate that is used to map warnings into errors or to suppress warnings. /// </param> /// <param name="level"> /// The base level of data to be sent to the listener. /// </param> /// <param name="eventMask"> /// If specified, an EventMask that allows selectively enabling or disabling events /// </param> /// <param name="onDisabledDueToDiskWriteFailure"> /// If specified, called if the listener encounters a disk-write failure such as an out of space condition. /// Otherwise, such conditions will throw an exception. /// </param> /// <param name="useCustomPipDescription"> /// If true, pip description string will be changed to (SemiStableHash, CustomerSuppliedPipDescription). /// If true but no custom description available, no changes will be made. /// </param> /// <param name="cancellationToken"> /// CancellationToken /// </param> /// <param name="maxStatusPips"> /// Maximum number of concurrently executing pips to render in Fancy Console view. /// </param> /// <param name="optimizeForAzureDevOps"> /// Whether console output should be optimized for Azure DevOps output. /// </param> public ConsoleEventListener( Events eventSource, IConsole console, DateTime baseTime, bool useCustomPipDescription, CancellationToken cancellationToken, string logsDirectory = null, bool notWorker = true, WarningMapper warningMapper = null, EventLevel level = EventLevel.Verbose, EventMask eventMask = null, DisabledDueToDiskWriteFailureEventHandler onDisabledDueToDiskWriteFailure = null, int maxStatusPips = DefaultMaxStatusPips, bool optimizeForAzureDevOps = false) : base(eventSource, baseTime, warningMapper, level, false, TimeDisplay.Seconds, eventMask, onDisabledDueToDiskWriteFailure, useCustomPipDescription : useCustomPipDescription) { Contract.Requires(eventSource != null); Contract.Requires(console != null); m_console = console; m_maxStatusPips = maxStatusPips; m_cancellationToken = cancellationToken; m_logsDirectory = logsDirectory; m_notWorker = notWorker; m_optimizeForAzureDevOps = optimizeForAzureDevOps; }
/// <summary> /// Initializes an instance. /// </summary> /// <param name="eventSource"> /// The event source to listen to. /// </param> /// <param name="warningMapper"> /// An optional delegate that is used to map warnings into errors or to suppress warnings. /// </param> public TrackingEventListener(Events eventSource, WarningMapper warningMapper = null) : base( eventSource, warningMapper, EventLevel.Verbose) { Contract.Requires(eventSource != null); m_eventCounts.Initialize(MaxEventIdExclusive); }
/// <nodoc /> public AzureDevOpsListener( Events eventSource, IConsole console, DateTime baseTime, BuildViewModel buildViewModel, bool useCustomPipDescription, [CanBeNull] WarningMapper warningMapper) : base(eventSource, baseTime, warningMapper: warningMapper, level: EventLevel.Verbose, captureAllDiagnosticMessages: false, timeDisplay: TimeDisplay.Seconds, useCustomPipDescription: useCustomPipDescription) { Contract.RequiresNotNull(console); Contract.RequiresNotNull(buildViewModel); m_console = console; m_buildViewModel = buildViewModel; }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="eventSource"> /// The event source to listen to. /// </param> /// <param name="baseTime"> /// The UTC time representing time 0 for this listener. /// </param> /// <param name="warningMapper"> /// An optional delegate that is used to map warnings into errors or to suppress warnings. /// </param> /// <param name="level"> /// The base level of data to be sent to the listener. /// </param> /// <param name="captureAllDiagnosticMessages"> /// If true, all messages tagged with <see cref="Keywords.Diagnostics" /> are captured. /// </param> /// <param name="timeDisplay"> /// The kind of time prefix to apply to each chunk of output. /// </param> /// <param name="eventMask"> /// If specified, an EventMask that allows selectively enabling or disabling events /// </param> /// <param name="onDisabledDueToDiskWriteFailure"> /// If specified, called if the listener encounters a disk-write failure such as an out of space condition. /// Otherwise, such conditions will throw an exception. /// </param> /// <param name="listenDiagnosticMessages"> /// If true, all messages tagged with <see cref="Keywords.Diagnostics" /> at or above <paramref name="level"/> are enabled but not captured unless diagnostics are enabled per-task. /// This is useful for StatisticsEventListener, where you need to listen diagnostics messages but capture only ones tagged with CommonInfrastructure task. /// </param> /// <param name="useCustomPipDescription"> /// If true, pip description string will be changed to (SemiStableHash, CustomerSuppliedPipDescription). /// If true but no custom description available, no changes will be made. /// </param> protected FormattingEventListener( Events eventSource, DateTime baseTime, WarningMapper warningMapper = null, EventLevel level = EventLevel.Verbose, bool captureAllDiagnosticMessages = false, TimeDisplay timeDisplay = TimeDisplay.None, EventMask eventMask = null, DisabledDueToDiskWriteFailureEventHandler onDisabledDueToDiskWriteFailure = null, bool listenDiagnosticMessages = false, bool useCustomPipDescription = false) : base(eventSource, warningMapper, level, captureAllDiagnosticMessages, eventMask, onDisabledDueToDiskWriteFailure, listenDiagnosticMessages) { Contract.Requires(eventSource != null); BaseTime = baseTime; TimeDisplay = timeDisplay; UseCustomPipDescription = useCustomPipDescription; }
/// <summary> /// Initializes an instance. /// </summary> /// <param name="eventSource"> /// The event source to listen to. /// </param> /// <param name="warningMapper"> /// An optional delegate that is used to map warnings into errors or to suppress warnings. /// </param> /// <param name="level"> /// The base level of data to be sent to the listener. /// </param> /// <param name="captureAllDiagnosticMessages"> /// If true, all messages tagged with <see cref="Keywords.Diagnostics" /> at or above <paramref name="level"/> are captured (rather than needing to be enabled per-task). /// </param> /// <param name="eventMask"> /// If specified, an EventMask that allows selectively enabling or disabling events /// </param> /// <param name="onDisabledDueToDiskWriteFailure"> /// If specified, called if the listener encounters a disk-write failure such as an out of space condition. /// Otherwise, such conditions will throw an exception. /// </param> /// <param name="listenDiagnosticMessages"> /// If true, all messages tagged with <see cref="Keywords.Diagnostics" /> at or above <paramref name="level"/> are enabled but not captured unless diagnostics are enabled per-task. /// This is useful for StatisticsEventListener, where you need to listen diagnostics messages but capture only ones tagged with CommonInfrastructure task. /// </param> protected BaseEventListener( Events eventSource, WarningMapper warningMapper, EventLevel level = EventLevel.Verbose, bool captureAllDiagnosticMessages = false, EventMask eventMask = null, DisabledDueToDiskWriteFailureEventHandler onDisabledDueToDiskWriteFailure = null, bool listenDiagnosticMessages = false) { Contract.Requires(eventSource != null); m_eventSource = eventSource; m_level = level; m_warningMapper = warningMapper; m_disabledDueToDiskWriteFailureEventHandler = onDisabledDueToDiskWriteFailure; m_eventMask = eventMask; // If user gives a /diag argument or listenDiagnosticMessage is passed as true to the constructor, // diagnostics messages should be enabled. At this point, we do not know whether this event listener will capture them. // Capturing the diagnostic messages depends on whether EnableTaskDiagnostics will be called or not. // If the /diag argument exists, EnableTaskDiagnostics method will always be called. m_diagnosticsEnabled = eventSource.HasDiagnosticsArgument || listenDiagnosticMessages; // captureAllDiagnosticMessages is true only for TestEventListeners. if (captureAllDiagnosticMessages) { m_diagnosticsEnabled = true; for (int i = 0; i < m_enableTaskDiagnostics.Length; i++) { m_enableTaskDiagnostics[i] = true; } } EnableEvents(eventSource, level, m_diagnosticsEnabled ? DiagnosticsKeywords : NormalKeywords); eventSource.RegisterEventListener(this); }
/// <summary> /// <see cref="TextWriterEventListener(Events, IEventWriter, DateTime, BuildXL.Utilities.Tracing.BaseEventListener.WarningMapper, EventLevel, TimeDisplay, EventMask, BaseEventListener.DisabledDueToDiskWriteFailureEventHandler, PathTranslator, bool)"/>. /// </summary> public TextWriterEventListener( Events eventSource, TextWriter writer, DateTime baseTime, WarningMapper warningMapper = null, EventLevel level = EventLevel.Verbose, TimeDisplay timeDisplay = TimeDisplay.None, EventMask eventMask = null, DisabledDueToDiskWriteFailureEventHandler onDisabledDueToDiskWriteFailure = null, PathTranslator pathTranslator = null, bool listenDiagnosticMessages = false) : this( eventSource, new TextEventWriter(writer), baseTime, warningMapper, level, timeDisplay, eventMask, onDisabledDueToDiskWriteFailure, pathTranslator, listenDiagnosticMessages) { }
public ConsoleEventListener(Events eventSource, DateTime baseTime, WarningMapper warningMapper = null, EventLevel level = EventLevel.Verbose, bool captureAllDiagnosticMessages = false, TimeDisplay timeDisplay = TimeDisplay.None, EventMask eventMask = null, DisabledDueToDiskWriteFailureEventHandler onDisabledDueToDiskWriteFailure = null, bool listenDiagnosticMessages = false, bool useCustomPipDescription = false) : base(eventSource, baseTime, warningMapper, level, captureAllDiagnosticMessages, timeDisplay, eventMask, onDisabledDueToDiskWriteFailure, listenDiagnosticMessages, useCustomPipDescription) { }
/// <summary> /// Initializes an instance. /// </summary> /// <param name="eventSource"> /// The event source to listen to. /// </param> /// <param name="baseTime"> /// The starting time that events are compared against for displaying relative time for messages. /// </param> /// <param name="warningMapper"> /// An optional delegate that is used to map warnings into errors or to suppress warnings. /// </param> public TrackingEventListener(Events eventSource, DateTime baseTime = default(DateTime), WarningMapper warningMapper = null) : base( eventSource, warningMapper, EventLevel.Verbose) { m_baseTime = baseTime == default(DateTime) ? DateTime.Now : baseTime; Contract.RequiresNotNull(eventSource); m_eventCounts.Initialize(MaxEventIdExclusive); }