/// <summary>
 /// Initalize this class with a central logger id identifying the central logger to which
 /// these events should consumed by. The redirector will send the messages to the registered sink to 
 /// be consumed
 /// </summary>
 /// <param name="loggerId">Id which will be attached to the build event arguments to indicate which logger the events came from</param>
 /// <param name="eventSink">sink which will initially consume the events</param>
 /// <exception cref="InternalErrorException">Eventsink is null</exception>
 /// <exception cref="InternalErrorException">LoggerId is less than 0</exception>
 internal EventRedirectorToSink(int loggerId, IBuildEventSink eventSink)
 {
     ErrorUtilities.VerifyThrow(eventSink != null, "eventSink is null");
     ErrorUtilities.VerifyThrow(loggerId >= 0, "loggerId should be greater or equal to 0");
     _centralLoggerId = loggerId;
     _sink = eventSink;
 }
Example #2
0
 /// <summary>
 /// Initalize this class with a central logger id identifying the central logger to which
 /// these events should consumed by. The redirector will send the messages to the registered sink to
 /// be consumed
 /// </summary>
 /// <param name="loggerId">Id which will be attached to the build event arguments to indicate which logger the events came from</param>
 /// <param name="eventSink">sink which will initially consume the events</param>
 /// <exception cref="InternalErrorException">Eventsink is null</exception>
 /// <exception cref="InternalErrorException">LoggerId is less than 0</exception>
 internal EventRedirectorToSink(int loggerId, IBuildEventSink eventSink)
 {
     ErrorUtilities.VerifyThrow(eventSink != null, "eventSink is null");
     ErrorUtilities.VerifyThrow(loggerId >= 0, "loggerId should be greater or equal to 0");
     _centralLoggerId = loggerId;
     _sink            = eventSink;
 }
Example #3
0
 /// <summary>
 /// Initializes the loggers on a node
 /// </summary>
 /// <param name="loggerDescriptions">The descriptions received from the Build Manager</param>
 /// <param name="forwardingLoggerSink">The sink used to transmit messages to the manager.</param>
 /// <param name="nodeId">The id of the node.</param>
 public void InitializeNodeLoggers(ICollection <LoggerDescription> loggerDescriptions, IBuildEventSink forwardingLoggerSink, int nodeId)
 {
     throw new NotImplementedException();
 }
Example #4
0
 /// <summary>
 /// Initializes the loggers on a node
 /// </summary>
 /// <param name="loggerDescriptions">The descriptions received from the Build Manager</param>
 /// <param name="forwardingLoggerSink">The sink used to transmit messages to the manager.</param>
 /// <param name="nodeId">The id of the node.</param>
 public void InitializeNodeLoggers(ICollection<LoggerDescription> loggerDescriptions, IBuildEventSink forwardingLoggerSink, int nodeId)
 {
     throw new NotImplementedException();
 }
Example #5
0
        /// <summary>
        /// In order to setup the forwarding loggers on a node, we need to take in the logger descriptions and initialize them.
        /// The method will create a forwarding logger, an eventRedirector which will redirect all forwarded messages to the forwardingLoggerSink.
        /// All forwarding loggers will use the same forwardingLoggerSink.
        /// </summary>
        /// <param name="descriptions">Collection of logger descriptions which we would like to use to create a set of forwarding loggers on a node</param>
        /// <param name="forwardingLoggerSink">The buildEventSink which the fowarding loggers will forward their events to</param>
        /// <param name="nodeId">The id of the node the logging services is on</param>
        /// <exception cref="InternalErrorException">When forwardingLoggerSink is null</exception>
        /// <exception cref="InternalErrorException">When loggerDescriptions is null</exception>
        public void InitializeNodeLoggers(ICollection<LoggerDescription> descriptions, IBuildEventSink forwardingLoggerSink, int nodeId)
        {
            lock (_lockObject)
            {
                ErrorUtilities.VerifyThrow(_serviceState != LoggingServiceState.Shutdown, " The object is shutdown, should not do any operations on a shutdown component");
                ErrorUtilities.VerifyThrow(forwardingLoggerSink != null, "forwardingLoggerSink was null");
                ErrorUtilities.VerifyThrow(descriptions != null, "loggerDescriptions was null");
                ErrorUtilities.VerifyThrow(descriptions.Count > 0, "loggerDescriptions was null");

                bool sinkAlreadyRegistered = false;
                int sinkId = -1;

                // Check to see if the forwardingLoggerSink has been registered before
                foreach (KeyValuePair<int, IBuildEventSink> sinkPair in _eventSinkDictionary)
                {
                    if (sinkPair.Value == forwardingLoggerSink)
                    {
                        sinkId = sinkPair.Key;
                        sinkAlreadyRegistered = true;
                    }
                }

                if (!sinkAlreadyRegistered)
                {
                    sinkId = _nextSinkId++;
                    _eventSinkDictionary.Add(sinkId, forwardingLoggerSink);
                }

                CreateFilterEventSource();

                foreach (LoggerDescription description in descriptions)
                {
                    IForwardingLogger forwardingLogger = description.CreateForwardingLogger();
                    forwardingLogger.Verbosity = description.Verbosity;
                    forwardingLogger.Parameters = description.LoggerSwitchParameters;
                    forwardingLogger.NodeId = nodeId;
                    forwardingLogger.BuildEventRedirector = new EventRedirectorToSink(description.LoggerId, forwardingLoggerSink);

                    // Initialize and register the forwarding logger
                    InitializeLogger(forwardingLogger, _filterEventSource);
                }
            }
        }