MuxLogger Class

Definition

This is a multiplexing logger. The purpose of this logger is to allow the registration and deregistration of multiple loggers during the build. This is to support the VS IDE scenario where loggers are registered and unregistered for each project system's build request. This means one physical build may have multiple logical builds each with their own set of loggers.

The Mux logger will register itself with the build manager as a regular central /l style logger. It will be responsible for receiving messages from the build manager and route them to the correct logger based on the logical build the message came from.

Requirements: 1) Multiplexing logger will be registered at the beginning of the build manager's Begin build Any loggers registered before the build manager actually started building will get the build started event at the same time as the MUX logger Any loggers registered after the build manager starts the build will get a synthesised build started event. The event cannot be cached because the timestamp of the build started event is determined when the event is created, caching the event would give incorrect build times in the loggers registered to the MUX.

2) The MUX logger will be initialized by the build manager.
    The mux will listen to all events on the event source from the build manager and will route events correctly to the registered loggers.

3) The MUX logger will be shutdown when the build is finished in end build . At this time it will un-register any loggers attached to it.

4) The MUX logger will log the build finished event when the project finished event for the first project started event is seen for each logger.

Registering Loggers:

The multiplexing logger will function in the following way: A logger will be passed to the MUX Register logger method with a submission ID which will be used to route a the message to the correct logger. A new event source will be created so that the logger passed in can be registered to that event source If the build started event has already been logged the MUX logger will create a new BuildStartedEvent and send that to the event source.

UnregisterLoggers: When a build submission is completed the UnregisterLoggers method will be called with the submission ID. At this point we will look up the success state of the project finished event for the submission ID and log a build finished event to the logger. The event source will be cleaned up. This may be interesting because the unregister will come from a thread other than what is doing the logging. This may create a Synchronization issue, if unregister is called while events are being logged.

public ref class MuxLogger : Microsoft::Build::Framework::INodeLogger
public class MuxLogger : Microsoft.Build.Framework.INodeLogger
type MuxLogger = class
    interface INodeLogger
    interface ILogger
Public Class MuxLogger
Implements INodeLogger
Inheritance
MuxLogger
Implements

Remarks

The MuxLogger generally functions as follows:

  • The MuxLogger is registered at the beginning of the build manager's Begin build.

    Any loggers registered before the build manager starts the build get the build-started event at the same time as the MuxLogger.

    Any loggers registered after the build manager starts the build get a synthesized build-started event. The event cannot be cached because the timestamp of the build-started event is determined when the event is created, and caching the event would give incorrect build times in the loggers registered to the MuxLogger.

  • The MuxLogger is initialized by the build manager

    The MuxLogger listens to all events on the event source from the build manager and routes events correctly to the registered loggers.

  • The MuxLogger is shutdown when the build is finished in end build. At this time, it unregisters any loggers attached to it.

  • The MuxLogger logs the build-finished event when the project-finished event for the first project-started event is seen for each logger.

The MuxLogger registers loggers in the following way:

  1. The logger is passed to the MuxLogger.RegisterLogger method with a submission ID that is used to route a message to that logger.

  2. The MuxLogger registers the logger to the MuxLogger event source.

  3. If the build-started event has already been logged, the MuxLogger creates a new build-started event and sends it to the logger's event source.

The MuxLogger unregisters loggers in the following way:

  1. When a build submission is completed, the MuxLogger.UnregisterLogger method is called with the submission ID for the logger.

  2. The MuxLogger looks up the success state of the project-finished event for the submission ID and logs a build-finished event to the logger.

  3. The MuxLogger cleans up the event source.

    Note that the unregister comes from a thread other than the logging thread and a synchronization issue could occur if unregister is called while events are being logged.

Constructors

MuxLogger()

Constructor.

Properties

IncludeEvaluationMetaprojects

Should evaluation events include generated metaprojects?

IncludeEvaluationProfiles

Should evaluation events include profiling information?

IncludeEvaluationPropertiesAndItems

Should properties and items be logged on ProjectEvaluationFinishedEventArgs instead of ProjectStartedEventArgs?

IncludeTaskInputs

Should task events include task inputs?

Parameters

Required for the ILoggerInterface

Verbosity

Required for ILogger interface

Methods

Initialize(IEventSource)

Initialize the logger.

Initialize(IEventSource, Int32)

Initialize the logger.

RegisterLogger(Int32, ILogger)

This method will register a logger on the MUX logger and then raise a build started event if the build started event has already been logged

Shutdown()

Shutdown the mux logger and clear out any state

UnregisterLoggers(Int32)

Unregisters all the loggers for a given submission id.

Applies to