/// <summary> /// This method is called by the node loggers to forward the events to cenral logger /// </summary> void IEventRedirector.ForwardEvent(BuildEventArgs buildEvent) { // Don't allow forwarding loggers to forward build started ErrorUtilities.VerifyThrowInvalidOperation(!(buildEvent is BuildStartedEventArgs), "DontForwardBuildStarted"); // Don't allow forwarding loggers to forward build finished ErrorUtilities.VerifyThrowInvalidOperation(!(buildEvent is BuildFinishedEventArgs), "DontForwardBuildFinished"); // Mark the event with the logger id metadata and post it to the queue NodeLoggingEventWithLoggerId loggingEvent = new NodeLoggingEventWithLoggerId(buildEvent, loggerId); loggingService.PostLoggingEvent(loggingEvent); }
/// <summary> /// This method is called by the node loggers to forward the events to cenral logger /// </summary> void IEventRedirector.ForwardEvent(BuildEventArgs buildEvent) { // Don't allow forwarding loggers to forward build started ErrorUtilities.VerifyThrowInvalidOperation(!(buildEvent is BuildStartedEventArgs), "DontForwardBuildStarted"); // Don't allow forwarding loggers to forward build finished ErrorUtilities.VerifyThrowInvalidOperation(!(buildEvent is BuildFinishedEventArgs), "DontForwardBuildFinished"); // Mark the event with the logger id metadata and post it to the queue NodeLoggingEventWithLoggerId loggingEvent = new NodeLoggingEventWithLoggerId(buildEvent, loggerId); loggingService.PostLoggingEvent(loggingEvent); }
/// <summary> /// Logs that the build has finished to a particular logger Id /// </summary> virtual internal void LogBuildFinished(bool success, int loggerId) { // If we're only logging critical events, don't risk causing all the resources to load by formatting // a string that won't get emitted anyway. string message = String.Empty; if (!OnlyLogCriticalEvents) { message = ResourceUtilities.FormatResourceString(success ? "BuildFinishedSuccess" : "BuildFinishedFailure"); } BuildFinishedEventArgs e = new BuildFinishedEventArgs(message, null /* no help keyword */, success); // Wrap the BuildFinished event so it is only sent to the loggers to // the specified logger id NodeLoggingEventWithLoggerId nodeEvent = new NodeLoggingEventWithLoggerId(e, loggerId); PostLoggingEvent(nodeEvent); }
/************************************************************************************************************************** * WARNING: Do not add overloads that allow raising events without specifying a file. In general ALL events should have a * file associated with them. We've received a LOT of feedback from dogfooders about the lack of information in our * events. If an event TRULY does not have an associated file, then String.Empty can be passed in for the file. However, * that burden should lie on the caller -- these wrapper methods should NOT make it easy to skip the filename. *************************************************************************************************************************/ /// <summary> /// Logs that the build has started with all loggers (only called on the main node) /// </summary> virtual internal void LogBuildStarted() { // If we're only logging critical events, don't risk causing all the resources to load by formatting // a string that won't get emitted anyway. string message = String.Empty; if (!OnlyLogCriticalEvents) { message = ResourceUtilities.FormatResourceString("BuildStarted"); } BuildStartedEventArgs e = new BuildStartedEventArgs(message, null /* no help keyword */); PostLoggingEvent(e); // Wrap the event to be sent to central loggers NodeLoggingEventWithLoggerId nodeEventToCentralLoggers = new NodeLoggingEventWithLoggerId(e, EngineLoggingServicesInProc.ALL_PRIVATE_EVENTSOURCES); PostLoggingEvent(nodeEventToCentralLoggers); }
internal void CreateFromStream(BinaryReader reader, Hashtable loggingTypeCache) { base.CreateFromStream(reader); int numberOfNodeEvents = reader.ReadInt32(); buildEvents = new NodeLoggingEvent[numberOfNodeEvents]; for (int i = 0; i < numberOfNodeEvents; i++) { NodeLoggingEvent e; if (reader.ReadByte() == 0) { e = new NodeLoggingEvent(); } else { e = new NodeLoggingEventWithLoggerId(); } e.CreateFromStream(reader, loggingTypeCache); buildEvents[i] = e; } }
public void TestLoggingEventWithIdCustomerSerialization() { Hashtable loggingTypeCacheWrites = new Hashtable(); GenericCustomBuildEventArg genericEvent = new GenericCustomBuildEventArg("FooFighter"); NodeLoggingEventWithLoggerId nodeEvent = new NodeLoggingEventWithLoggerId(genericEvent, 4); stream.Position = 0; nodeEvent.WriteToStream(writer, loggingTypeCacheWrites); long streamWriteEndPosition = stream.Position; stream.Position = 0; Hashtable loggingTypeCacheReads = new Hashtable(); NodeLoggingEventWithLoggerId nodeEvent2 = new NodeLoggingEventWithLoggerId(null,-1); nodeEvent2.CreateFromStream(reader, loggingTypeCacheReads); long streamReadEndPosition = stream.Position; Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream end positions should be equal"); // Only checking loggingId because the serialization of the events are checked in the above test Assert.AreEqual(nodeEvent.LoggerId, nodeEvent2.LoggerId, "Expected LoggerId to match"); Assert.IsTrue(string.Compare(((GenericCustomBuildEventArg)nodeEvent.BuildEvent).customField, ((GenericCustomBuildEventArg)nodeEvent2.BuildEvent).customField, StringComparison.OrdinalIgnoreCase) == 0); }
internal void CreateFromStream(BinaryReader reader, Hashtable loggingTypeCache) { base.CreateFromStream(reader); int numberOfNodeEvents = reader.ReadInt32(); buildEvents = new NodeLoggingEvent[numberOfNodeEvents]; for (int i = 0; i < numberOfNodeEvents; i++) { NodeLoggingEvent e = null; if (reader.ReadByte() == 0) { e = new NodeLoggingEvent(); } else { e = new NodeLoggingEventWithLoggerId(); } e.CreateFromStream(reader, loggingTypeCache); buildEvents[i] = e; } }
/// <summary> /// Logs that the build has finished to a particular logger Id /// </summary> virtual internal void LogBuildFinished(bool success, int loggerId) { // If we're only logging critical events, don't risk causing all the resources to load by formatting // a string that won't get emitted anyway. string message = String.Empty; if (!OnlyLogCriticalEvents) { message = ResourceUtilities.FormatResourceString(success ? "BuildFinishedSuccess" : "BuildFinishedFailure"); } BuildFinishedEventArgs e = new BuildFinishedEventArgs(message, null /* no help keyword */, success); // Wrap the BuildFinished event so it is only sent to the loggers to // the specified logger id NodeLoggingEventWithLoggerId nodeEvent = new NodeLoggingEventWithLoggerId(e, loggerId); PostLoggingEvent(nodeEvent); }
/************************************************************************************************************************** * WARNING: Do not add overloads that allow raising events without specifying a file. In general ALL events should have a * file associated with them. We've received a LOT of feedback from dogfooders about the lack of information in our * events. If an event TRULY does not have an associated file, then String.Empty can be passed in for the file. However, * that burden should lie on the caller -- these wrapper methods should NOT make it easy to skip the filename. *************************************************************************************************************************/ /// <summary> /// Logs that the build has started with all loggers (only called on the main node) /// </summary> virtual internal void LogBuildStarted() { // If we're only logging critical events, don't risk causing all the resources to load by formatting // a string that won't get emitted anyway. string message = String.Empty; if (!OnlyLogCriticalEvents) { message = ResourceUtilities.FormatResourceString("BuildStarted"); } BuildStartedEventArgs e = new BuildStartedEventArgs(message, null /* no help keyword */); PostLoggingEvent(e); // Wrap the event to be sent to central loggers NodeLoggingEventWithLoggerId nodeEventToCentralLoggers = new NodeLoggingEventWithLoggerId(e, EngineLoggingServicesInProc.ALL_PRIVATE_EVENTSOURCES); PostLoggingEvent(nodeEventToCentralLoggers); }