public void SetEffectiveSourceInfo(LoggerSourceInfo logSource) { lock (queueMutex) { effectiveSourceInfo = logSource; } }
protected int InnerGetLoggerID(string loggerName) { int lid = LoggerID_Invalid; { if (loggerNameToIDMap.TryGetValue(loggerName ?? String.Empty, out lid)) return (InnerIsLoggerIDValid(lid) ? lid : LoggerID_Invalid); // the name was not in the table: need to create a new one lid = perLoggerIDInfoList.Count; perLoggerIDInfoList.Add(new PerLoggerIDInfo(lid)); loggerNameToIDMap.Add(loggerName, lid); PerLoggerIDInfo lInfo = perLoggerIDInfoList [lid]; LoggerSourceInfo sourceID = new LoggerSourceInfo(lid, loggerName, lInfo.seqLoggerConfigSource.LoggerConfigSource); lInfo.sourceID = sourceID; lInfo.DistGroupConfig = distGroupIDInfoList [DistGroupID_Default].ActiveLoggerConfig; InnerRemapLoggerToDistGroup(lid); } return lid; }
/// <summary>request distribution to start support for queued logging</summary> public void StartQueuedMessageDelivery() { // use preliminary asynchronous MT safe test to determine if the thread is already started (do not need to lock in that case) if (mesgQueueDistThread != null && mesgQueue != null && mesgQueue.IsEnabled) return; lock (distMutex) { // retest after owning lock to determine if the thread is already started if (mesgQueueDistThread != null && mesgQueue != null && mesgQueue.IsEnabled) return; // enable the thread and start the queue service thread if (mesgQueue == null) mesgQueue = new MessageQueue(MesgQueueSize); LoggerSourceInfo lsInfo = new LoggerSourceInfo(LoggerID_InternalLogger, "LogDist.InternalMesgQueue", mesgQueueLoggerGateSource.LoggerConfigSource); mesgQueue.SetEffectiveSourceInfo(lsInfo); mesgQueue.SetNotifyOnEnqueue(mesgQueueDistThreadWakeupNotification); mesgQueue.EnableQueue(); if (mesgQueue != null && mesgQueue.IsEnabled) { mesgQueueDistThread = new System.Threading.Thread(MesgQueueDistThreadFcn) { IsBackground = true, Name = "LogDist.QueuedLoggerRelay", }; mesgQueueDistThread.Start(); } if (mesgQueue == null || !mesgQueue.IsEnabled || mesgQueueDistThread == null) Utils.Asserts.TakeBreakpointAfterFault("LMD::StartQueuedMessageDelivery MesgQueue did not enable or thread not created."); } }
volatile bool shutdown = false; //!< volatile to support testing outside of lock ownership. changes are still done inside lock #endregion Fields #region Constructors public LogMessageDistributionImpl() { distSourceID = new LoggerSourceInfo(LoggerID_InternalLogger, "LogMessageDistributionImpl"); // define the default distribution group. Its name is the name that the distribution uses if // it is trying to emit a message. const int defaultDistGroupID = DistGroupID_Default; PerDistGroupIDInfo dgInfo = null; if (distGroupIDInfoList.Count == 0) { dgInfo = new PerDistGroupIDInfo(distGroupIDInfoList.Count, DefaultDistributionGroupName); distGroupIDInfoList.Add(dgInfo); distGroupNameToIDMap.Add(dgInfo.DistGroupName, dgInfo.DistGroupID); } if (!InnerIsDistGroupIDValid(defaultDistGroupID)) Asserts.TakeBreakpointAfterFault("DistGroupID_Default is not valid after initializing Distribution Group table."); // create the loggerID used for messages that come from the distribution system int lmdLoggerID = InnerGetLoggerID("LogMessageDistributionImpl"); if (InnerIsLoggerIDValid(lmdLoggerID)) distSourceID = perLoggerIDInfoList [lmdLoggerID].sourceID; else Utils.Asserts.TakeBreakpointAfterFault("A valid DistSourceID could not be created"); }
/// <summary>Constructor</summary> /// <param name="logMesgHandler">Gives the LMH to which emitted messages will be passed.</param> public LogMesgHandlerLogger(ILogMessageHandler logMesgHandler) : base(logMesgHandler.Name, string.Empty, logMesgHandler.LoggerConfig.LogGate, false) { lmh = logMesgHandler; if (lmh == null) Utils.Asserts.TakeBreakpointAfterFault("LogMesgHandlerLogger: LMH == null"); sourceInfo = new LoggerSourceInfo(LoggerID_InternalLogger, Name); }