/// <summary> /// Initialize the node with the id and the callback object /// </summary> internal Node ( int nodeId, LoggerDescription[] nodeLoggers, IEngineCallback parentCallback, BuildPropertyGroup parentGlobalProperties, ToolsetDefinitionLocations toolsetSearchLocations, string parentStartupDirectory ) { this.nodeId = nodeId; this.parentCallback = parentCallback; this.exitNodeEvent = new ManualResetEvent(false); this.buildRequests = new Queue<BuildRequest>(); this.requestToLocalIdMapping = new Hashtable(); this.lastRequestIdUsed = 0; this.centralizedLogging = false; this.nodeLoggers = nodeLoggers; this.localEngine = null; this.launchedEngineLoopThread = false; this.nodeShutdown = false; this.parentGlobalProperties = parentGlobalProperties; this.toolsetSearchLocations = toolsetSearchLocations; this.parentStartupDirectory = parentStartupDirectory; }
/// <summary> /// Register node logger with all currently available providers /// </summary> /// <param name="loggerDescription"></param> internal void RegisterNodeLogger(LoggerDescription loggerDescription) { foreach (INodeProvider nodeProvider in nodeProviders) { nodeProvider.RegisterNodeLogger(loggerDescription); } }
public void RegisterNodeLogger(LoggerDescription loggerDescription) { ErrorUtilities.VerifyThrow(nodeLoggers != null, "Must call Initialize first"); ErrorUtilities.VerifyThrow(loggerDescription != null, "Logger description should be non-null"); if (!nodeLoggers.Contains(loggerDescription)) { nodeLoggers.Add(loggerDescription); } }
internal override void CreateFromStream(BinaryReader reader) { base.CreateFromStream(reader); #region EnvironmentVariables int numberOfVariables = reader.ReadInt32(); environmentVariables = new Hashtable(numberOfVariables); for (int i = 0; i < numberOfVariables; i++) { string key = reader.ReadString(); string variable = reader.ReadString(); environmentVariables.Add(key, variable); } #endregion #region NodeLoggers if (reader.ReadByte() == 0) { nodeLoggers = null; } else { int numberOfLoggers = reader.ReadInt32(); nodeLoggers = new LoggerDescription[numberOfLoggers]; for (int i = 0; i < numberOfLoggers; i++) { LoggerDescription logger = new LoggerDescription(); logger.CreateFromStream(reader); nodeLoggers[i] = logger; } } #endregion nodeId = reader.ReadInt32(); parentProcessId = reader.ReadInt32(); #region ParentGlobalProperties if (reader.ReadByte() == 0) { parentGlobalProperties = null; } else { parentGlobalProperties = new BuildPropertyGroup(); parentGlobalProperties.CreateFromStream(reader); } #endregion toolsetSearchLocations = (ToolsetDefinitionLocations)reader.ReadByte(); parentStartupDirectory = (string)reader.ReadString(); }
static void Main(string[] args) { // We need to tell MSBuild where msbuild.exe is, so it can launch child nodes string parameters = @"MSBUILDLOCATION=" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.System) + @"\..\Microsoft.NET\Framework\v3.5"; // We need to tell MSBuild whether nodes should hang around for 60 seconds after the build is done in case they are needed again bool nodeReuse = true; // e.g. if (!nodeReuse) { parameters += ";NODEREUSE=false"; } // We need to tell MSBuild the maximum number of nodes to use. It is usually fastest to pick about the same number as you have CPU cores int maxNodeCount = 3; // e.g. // Create the engine with this information Engine buildEngine = new Engine(null, ToolsetDefinitionLocations.Registry | ToolsetDefinitionLocations.ConfigurationFile, maxNodeCount, parameters); // Create a file logger with a matching forwarding logger, e.g. FileLogger fileLogger = new FileLogger(); fileLogger.Verbosity = LoggerVerbosity.Detailed; Assembly engineAssembly = Assembly.GetAssembly(typeof(Engine)); string loggerAssemblyName = engineAssembly.GetName().FullName; LoggerDescription fileLoggerForwardingLoggerDescription = new LoggerDescription("Microsoft.Build.BuildEngine.ConfigurableForwardingLogger", loggerAssemblyName, null, String.Empty, LoggerVerbosity.Detailed); // Create a regular console logger too, e.g. ConsoleLogger logger = new ConsoleLogger(); logger.Verbosity = LoggerVerbosity.Normal; // Register all of these loggers buildEngine.RegisterDistributedLogger(fileLogger, fileLoggerForwardingLoggerDescription); buildEngine.RegisterLogger(logger); // Do a build buildEngine.BuildProjectFile("root.proj"); // Finish cleanly buildEngine.Shutdown(); }
public void LoggerDescriptionCustomSerialization() { string className = "Class"; string loggerAssemblyName = "Class"; string loggerFileAssembly = null; string loggerSwitchParameters = "Class"; LoggerVerbosity verbosity = LoggerVerbosity.Detailed; LoggerDescription description = new LoggerDescription(className, loggerAssemblyName, loggerFileAssembly, loggerSwitchParameters, verbosity); MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); BinaryReader reader = new BinaryReader(stream); try { stream.Position = 0; description.WriteToStream(writer); long streamWriteEndPosition = stream.Position; stream.Position = 0; LoggerDescription description2 = new LoggerDescription(); description2.CreateFromStream(reader); long streamReadEndPosition = stream.Position; Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream end positions should be equal"); Assert.IsTrue(description.Verbosity == description2.Verbosity, "Expected Verbosity to Match"); Assert.IsTrue(description.LoggerId == description2.LoggerId, "Expected Verbosity to Match"); Assert.IsTrue(string.Compare(description.LoggerSwitchParameters, description2.LoggerSwitchParameters, StringComparison.OrdinalIgnoreCase) == 0, "Expected LoggerSwitchParameters to Match"); Assert.IsTrue(string.Compare(description.Name, description2.Name, StringComparison.OrdinalIgnoreCase) == 0, "Expected Name to Match"); } finally { reader.Close(); writer = null; stream = null; } }
void INodeProvider.RegisterNodeLogger(LoggerDescription description ) { if ( description == null ) { throw new ArgumentException("Logger description should be non-null"); } }
public void BuildProjectFilesInParallel() { //Gets the currently loaded assembly in which the specified class is defined Assembly engineAssembly = Assembly.GetAssembly(typeof(Engine)); string loggerClassName = "Microsoft.Build.BuildEngine.ConfigurableForwardingLogger"; string loggerAssemblyName = engineAssembly.GetName().FullName; LoggerDescription forwardingLoggerDescription = new LoggerDescription(loggerClassName, loggerAssemblyName, null, null, LoggerVerbosity.Normal); string[] fileNames = new string[10]; string traversalProject = TraversalProjectFile("ABC"); string[][] targetNamesPerProject = new string[fileNames.Length][]; IDictionary[] targetOutPutsPerProject = new IDictionary[fileNames.Length]; BuildPropertyGroup[] globalPropertiesPerProject = new BuildPropertyGroup[fileNames.Length]; string[] tempfilesToDelete = new string[fileNames.Length]; Engine engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+AppDomain.CurrentDomain.BaseDirectory); engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal)); try { for (int i = 0; i < fileNames.Length; i++) { string[] ProjectFiles1 = CreateGlobalPropertyProjectFileWithExtension("ABC"); fileNames[i] = ProjectFiles1[0]; tempfilesToDelete[i] = ProjectFiles1[1]; targetNamesPerProject[i] = new string[] { "Build" }; } // Test building a traversal engine.BuildProjectFile(traversalProject); engine.Shutdown(); // Test building the same set of files in parallel Console.Out.WriteLine("1:"+Process.GetCurrentProcess().MainModule.FileName); Console.Out.WriteLine("2:" + AppDomain.CurrentDomain.BaseDirectory); engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory); engine.RegisterDistributedLogger(new ConsoleLogger(LoggerVerbosity.Normal), forwardingLoggerDescription); engine.BuildProjectFiles(fileNames, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]); engine.Shutdown(); // Do the same using singleproc engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 4, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory); engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal)); engine.BuildProjectFile(traversalProject); engine.Shutdown(); engine = new Engine(null, ToolsetDefinitionLocations.ConfigurationFile | ToolsetDefinitionLocations.Registry, 1, "msbuildlocation="+ AppDomain.CurrentDomain.BaseDirectory); engine.RegisterLogger(new ConsoleLogger(LoggerVerbosity.Normal)); engine.BuildProjectFiles(fileNames, targetNamesPerProject, globalPropertiesPerProject, targetOutPutsPerProject, BuildSettings.None, new string[fileNames.Length]); } finally { engine.Shutdown(); for (int i = 0; i < fileNames.Length; i++) { File.Delete(fileNames[i]); File.Delete(tempfilesToDelete[i]); } File.Delete(traversalProject); } }
internal override void CreateFromStream(BinaryReader reader) { base.CreateFromStream(reader); #region EnvironmentVariables int numberOfVariables = reader.ReadInt32(); environmentVariables = new Hashtable(numberOfVariables); for (int i = 0; i < numberOfVariables; i++) { string key = reader.ReadString(); string variable = reader.ReadString(); environmentVariables.Add(key, variable); } #endregion #region NodeLoggers if (reader.ReadByte() == 0) { nodeLoggers = null; } else { int numberOfLoggers = reader.ReadInt32(); nodeLoggers = new LoggerDescription[numberOfLoggers]; for (int i = 0; i < numberOfLoggers; i++) { LoggerDescription logger = new LoggerDescription(); logger.CreateFromStream(reader); nodeLoggers[i] = logger; } } #endregion nodeId = reader.ReadInt32(); parentProcessId = reader.ReadInt32(); #region ParentGlobalProperties if (reader.ReadByte() == 0) { parentGlobalProperties = null; } else { parentGlobalProperties = new BuildPropertyGroup(); parentGlobalProperties.CreateFromStream(reader); } #endregion toolsetSearchLocations = (ToolsetDefinitionLocations)reader.ReadByte(); parentStartupDirectory = (string)reader.ReadString(); }
internal LocalCallDescriptorForInitializeNode ( Hashtable environmentVariablesToSend, LoggerDescription[] nodeLoggers, int nodeId, BuildPropertyGroup parentGlobalProperties, ToolsetDefinitionLocations toolsetSearchLocations, int parentProcessId, string parentStartupDirectory ) : base(LocalCallType.InitializeNode) { this.environmentVariables = environmentVariablesToSend; this.parentGlobalProperties = parentGlobalProperties; this.toolsetSearchLocations = toolsetSearchLocations; this.nodeLoggers = nodeLoggers; this.nodeId = nodeId; this.parentProcessId = parentProcessId; this.parentStartupDirectory = parentStartupDirectory; }
public void TestItemsInandOutOfSharedMemory() { string name = Guid.NewGuid().ToString(); // Create the shared memory buffer SharedMemory readSharedMemory = new SharedMemory ( name, SharedMemoryType.ReadOnly, true ); SharedMemory writeSharedMemory = new SharedMemory ( name, SharedMemoryType.WriteOnly, true ); DualQueue<LocalCallDescriptor> queue = new DualQueue<LocalCallDescriptor>(); DualQueue<LocalCallDescriptor> hiPriQueue = new DualQueue<LocalCallDescriptor>(); LocalCallDescriptorForPostLoggingMessagesToHost LargeLogEvent = CreatePostMessageCallDescriptor(1); LocalCallDescriptorForUpdateNodeSettings updateNodeSettings = new LocalCallDescriptorForUpdateNodeSettings(true, true, true); LocalCallDescriptorForPostBuildResult buildResult = new LocalCallDescriptorForPostBuildResult(CreateBuildResult()); LocalCallDescriptorForPostBuildRequests buildRequests = new LocalCallDescriptorForPostBuildRequests(CreateBuildRequest()); LocalCallDescriptorForRequestStatus requestStatus = new LocalCallDescriptorForRequestStatus(4); LocalCallDescriptorForPostStatus nodeStatusNoExcept = new LocalCallDescriptorForPostStatus(new NodeStatus(1, true, 2, 3, 4, true)); LocalCallDescriptorForPostStatus nodeStatusExcept = new LocalCallDescriptorForPostStatus(new NodeStatus(new Exception("I am bad"))); LocalCallDescriptorForShutdownNode shutdownNode = new LocalCallDescriptorForShutdownNode(Node.NodeShutdownLevel.BuildCompleteSuccess, true); LocalCallDescriptorForShutdownComplete shutdownComplete = new LocalCallDescriptorForShutdownComplete(Node.NodeShutdownLevel.BuildCompleteFailure, 0); LocalCallDescriptorForInitializationComplete initializeComplete = new LocalCallDescriptorForInitializationComplete(99); BuildPropertyGroup propertyGroup = new BuildPropertyGroup(); BuildProperty propertyToAdd = new BuildProperty("PropertyName", "Value"); propertyGroup.SetProperty(propertyToAdd); CacheEntry[] entries = CreateCacheEntries(); LocalCallDescriptorForGettingCacheEntriesFromHost getCacheEntries = new LocalCallDescriptorForGettingCacheEntriesFromHost(new string[] { "Hi", "Hello" }, "Name", propertyGroup, "3.5", CacheContentType.Properties); LocalCallDescriptorForPostingCacheEntriesToHost postCacheEntries = new LocalCallDescriptorForPostingCacheEntriesToHost(entries, "ScopeName", propertyGroup, "3.5", CacheContentType.BuildResults); LocalReplyCallDescriptor replyDescriptor1 = new LocalReplyCallDescriptor(1, entries); LocalReplyCallDescriptor replyDescriptor2 = new LocalReplyCallDescriptor(6, "Foo"); IDictionary environmentVariables = Environment.GetEnvironmentVariables(); Hashtable environmentVariablesHashtable = new Hashtable(environmentVariables); string className = "Class"; string loggerAssemblyName = "Class"; string loggerFileAssembly = null; string loggerSwitchParameters = "Class"; LoggerVerbosity verbosity = LoggerVerbosity.Detailed; LoggerDescription description = new LoggerDescription(className, loggerAssemblyName, loggerFileAssembly, loggerSwitchParameters, verbosity); LocalCallDescriptorForInitializeNode initializeNode = new LocalCallDescriptorForInitializeNode(environmentVariablesHashtable, new LoggerDescription[] { description }, 4, propertyGroup, ToolsetDefinitionLocations.ConfigurationFile, 5, String.Empty); queue.Enqueue(LargeLogEvent); queue.Enqueue(updateNodeSettings); queue.Enqueue(buildResult); queue.Enqueue(buildRequests); queue.Enqueue(requestStatus); queue.Enqueue(nodeStatusNoExcept); queue.Enqueue(nodeStatusExcept); queue.Enqueue(shutdownNode); queue.Enqueue(shutdownComplete); queue.Enqueue(initializeComplete); queue.Enqueue(getCacheEntries); queue.Enqueue(postCacheEntries); queue.Enqueue(replyDescriptor1); queue.Enqueue(replyDescriptor2); queue.Enqueue(initializeNode); writeSharedMemory.Write(queue, hiPriQueue, false); IList localCallDescriptorList = readSharedMemory.Read(); Assert.IsTrue(localCallDescriptorList.Count == 15); LocalCallDescriptorForPostLoggingMessagesToHost messageCallDescriptor = localCallDescriptorList[0] as LocalCallDescriptorForPostLoggingMessagesToHost; VerifyPostMessagesToHost(messageCallDescriptor, 1); LocalCallDescriptorForUpdateNodeSettings updateSettingsCallDescriptor = localCallDescriptorList[1] as LocalCallDescriptorForUpdateNodeSettings; VerifyUpdateSettings(updateSettingsCallDescriptor); LocalCallDescriptorForPostBuildResult buildResultCallDescriptor = localCallDescriptorList[2] as LocalCallDescriptorForPostBuildResult; CompareBuildResult(buildResultCallDescriptor); LocalCallDescriptorForPostBuildRequests buildRequestsCallDescriptor = localCallDescriptorList[3] as LocalCallDescriptorForPostBuildRequests; ComparebuildRequests(buildRequestsCallDescriptor); LocalCallDescriptorForRequestStatus requestStatusCallDescriptor = localCallDescriptorList[4] as LocalCallDescriptorForRequestStatus; Assert.IsTrue(requestStatusCallDescriptor.RequestId == 4); LocalCallDescriptorForPostStatus nodeStatus1CallDescriptor = localCallDescriptorList[5] as LocalCallDescriptorForPostStatus; VerifyNodeStatus1(nodeStatus1CallDescriptor); LocalCallDescriptorForPostStatus nodeStatus2CallDescriptor = localCallDescriptorList[6] as LocalCallDescriptorForPostStatus; VerifyNodeStatus2(nodeStatus2CallDescriptor); LocalCallDescriptorForShutdownNode shutdownNodeCallDescriptor = localCallDescriptorList[7] as LocalCallDescriptorForShutdownNode; Assert.IsTrue(shutdownNodeCallDescriptor.ShutdownLevel == Node.NodeShutdownLevel.BuildCompleteSuccess); Assert.IsTrue(shutdownNodeCallDescriptor.ExitProcess); LocalCallDescriptorForShutdownComplete shutdownNodeCompleteCallDescriptor = localCallDescriptorList[8] as LocalCallDescriptorForShutdownComplete; Assert.IsTrue(shutdownNodeCompleteCallDescriptor.ShutdownLevel == Node.NodeShutdownLevel.BuildCompleteFailure); LocalCallDescriptorForInitializationComplete initializeCompleteCallDescriptor = localCallDescriptorList[9] as LocalCallDescriptorForInitializationComplete; Assert.IsTrue(initializeCompleteCallDescriptor.ProcessId == 99); LocalCallDescriptorForGettingCacheEntriesFromHost getCacheEntriesCallDescriptor = localCallDescriptorList[10] as LocalCallDescriptorForGettingCacheEntriesFromHost; VerifyGetCacheEntryFromHost(getCacheEntriesCallDescriptor); LocalCallDescriptorForPostingCacheEntriesToHost postCacheEntriesCallDescriptor = localCallDescriptorList[11] as LocalCallDescriptorForPostingCacheEntriesToHost; Assert.IsTrue(string.Compare(postCacheEntriesCallDescriptor.ScopeName, "ScopeName", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(string.Compare(postCacheEntriesCallDescriptor.ScopeProperties["PropertyName"].Value, "Value", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(string.Compare(postCacheEntriesCallDescriptor.ScopeToolsVersion, "3.5", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(postCacheEntriesCallDescriptor.ContentType == CacheContentType.BuildResults); VerifyGetCacheEntries(postCacheEntriesCallDescriptor.Entries); LocalReplyCallDescriptor reply1CallDescriptor = localCallDescriptorList[12] as LocalReplyCallDescriptor; Assert.IsTrue(reply1CallDescriptor.RequestingCallNumber == 1); VerifyGetCacheEntries((CacheEntry[])reply1CallDescriptor.ReplyData); LocalReplyCallDescriptor reply2CallDescriptor = localCallDescriptorList[13] as LocalReplyCallDescriptor; Assert.IsTrue(reply2CallDescriptor.RequestingCallNumber == 6); Assert.IsTrue(string.Compare("Foo", (string)reply2CallDescriptor.ReplyData, StringComparison.OrdinalIgnoreCase) == 0); LocalCallDescriptorForInitializeNode initializeCallDescriptor = localCallDescriptorList[14] as LocalCallDescriptorForInitializeNode; Assert.IsTrue(initializeCallDescriptor.ParentProcessId == 5); Assert.IsTrue(initializeCallDescriptor.NodeId == 4); Assert.IsTrue(initializeCallDescriptor.ToolsetSearchLocations == ToolsetDefinitionLocations.ConfigurationFile); Assert.IsTrue(string.Compare(initializeCallDescriptor.ParentGlobalProperties["PropertyName"].Value, "Value", StringComparison.OrdinalIgnoreCase) == 0); Assert.IsTrue(string.Compare(initializeCallDescriptor.NodeLoggers[0].Name, "Class", StringComparison.OrdinalIgnoreCase) == 0); IDictionary variables = Environment.GetEnvironmentVariables(); Assert.IsTrue(variables.Count == initializeCallDescriptor.EnvironmentVariables.Count); foreach (string key in variables.Keys) { Assert.IsTrue(string.Compare((string)initializeCallDescriptor.EnvironmentVariables[key], (string)variables[key], StringComparison.OrdinalIgnoreCase) == 0); } writeSharedMemory.Reset(); readSharedMemory.Reset(); readSharedMemory = null; writeSharedMemory = null; }
/// <summary> /// This methods activates the local node /// </summary> internal void Activate ( Hashtable environmentVariables, LoggerDescription[] nodeLoggers, int nodeId, BuildPropertyGroup parentGlobalProperties, ToolsetDefinitionLocations toolsetSearchLocations, int parentId, string parentStartupDirectory ) { ErrorUtilities.VerifyThrow(node == null, "Expected node to be null on activation."); this.parentProcessId = parentId; engineCallback.Reset(); inUseEvent.Set(); // Clear the environment so that we dont have extra variables laying around, this // may be a performance hog but needs to be done IDictionary variableDictionary = Environment.GetEnvironmentVariables(); foreach (string variableName in variableDictionary.Keys) { Environment.SetEnvironmentVariable(variableName, null); } foreach(string key in environmentVariables.Keys) { Environment.SetEnvironmentVariable(key,(string)environmentVariables[key]); } // Host the msbuild engine and system node = new Node(nodeId, nodeLoggers, engineCallback, parentGlobalProperties, toolsetSearchLocations, parentStartupDirectory); // Write the initialization complete event out directly LocalCallDescriptorForInitializationComplete callDescriptor = new LocalCallDescriptorForInitializationComplete(Process.GetCurrentProcess().Id); // Post the message indicating that the initialization is complete engineCallback.PostMessageToParent(callDescriptor, true); }
/// <summary> /// Called to register distributed loggers with the engine. /// This method is not thread safe. All loggers should registered prior to /// starting the build in order to guarantee uniform behavior /// </summary> /// <exception cref="LoggerException">Logger indicating it failed in a controlled way</exception> /// <exception cref="InternalLoggerException">Logger threw arbitrary exception</exception> public void RegisterDistributedLogger(ILogger centralLogger, LoggerDescription forwardingLogger) { error.VerifyThrowArgumentNull(forwardingLogger, "forwardingLogger"); if (centralLogger == null) { centralLogger = new NullCentralLogger(); } // If this is the first distributed logger we need to create an event source for local // forwarding loggers if (eventSourceForForwarding == null) { eventSourceForForwarding = new EventSource(); ((EngineLoggingServicesInProc)primaryLoggingServices).RegisterEventSource (EngineLoggingServicesInProc.LOCAL_FORWARDING_EVENTSOURCE, eventSourceForForwarding); } // Assign a unique logger Id to this distributed logger int loggerId = lastUsedLoggerId; lastUsedLoggerId++; forwardingLogger.LoggerId = loggerId; //Create and configure the local node logger IForwardingLogger localForwardingLogger = null; try { localForwardingLogger = forwardingLogger.CreateForwardingLogger(); // Check if the class was not found in the assembly if (localForwardingLogger == null) { InternalLoggerException.Throw(null, null, "LoggerNotFoundError", true, forwardingLogger.Name); } // Configure the object EventRedirector newRedirector = new EventRedirector(forwardingLogger.LoggerId, primaryLoggingServices); localForwardingLogger.BuildEventRedirector = newRedirector; localForwardingLogger.Parameters = forwardingLogger.LoggerSwitchParameters; localForwardingLogger.Verbosity = forwardingLogger.Verbosity; localForwardingLogger.NodeId= nodeId; // Convert the path to the logger DLL to full path before passing it to the node provider forwardingLogger.ConvertPathsToFullPaths(); } // Polite logger failure catch (LoggerException) { throw; } // Logger class was not found catch (InternalLoggerException) { throw; } catch (Exception e) { InternalLoggerException.Throw(e, null, "LoggerCreationError", true, forwardingLogger.Name); } // Register the local forwarding logger to listen for all local events RegisterLoggerInternal(localForwardingLogger, eventSourceForForwarding, true); //Register this logger's node logger with the node manager so that all //the nodes instantiate this node logger and forward the events nodeManager.RegisterNodeLogger(forwardingLogger); // Create a private event source that will be used by this distributed logger and register // the central logger with the engine EventSource privateEventSource = new EventSource(); RegisterLoggerInternal(centralLogger, privateEventSource, false); // Register the private event source with the logging services so that the events from the local // node logger are forwarded to the central logger ((EngineLoggingServicesInProc)primaryLoggingServices).RegisterEventSource(forwardingLogger.LoggerId, privateEventSource); }
/// <summary> /// Register node logger with all currently available providers /// </summary> /// <param name="loggerDescription"></param> internal void RegisterNodeLogger(LoggerDescription loggerDescription) { foreach (INodeProvider nodeProvider in nodeProviders) { nodeProvider.RegisterNodeLogger(loggerDescription); } }
public void RegisterNodeLogger(LoggerDescription loggerDescription) { ErrorUtilities.VerifyThrow(nodeLoggers != null, "Must call Initialize first"); ErrorUtilities.VerifyThrow(loggerDescription != null, "Logger description should be non-null"); if (!nodeLoggers.Contains(loggerDescription)) { nodeLoggers.Add(loggerDescription); } }