/// <summary> /// Multiple targetLMH constructor. Derives LoggingConfig values from the given targetLMH /// </summary> /// <param name="name">Gives the name of this LMH - different than the names of the target LMH instances</param> /// <param name="targetLMHArray">Gives the set of LMH instance that are to be given the dequeued LogMessages.</param> /// <param name="maxQueueSize">Defines te maximum number of messages that can be held internally before messages are lost.</param> public QueueLogMessageHandler(string name, ILogMessageHandler[] targetLMHArray, int maxQueueSize) : base(name, LogGate.None, false, false) { targetLMHArray = targetLMHArray ?? emptyLMHArray; LogGate logGate = LogGate.None; bool recordSourceStackFrame = false; bool supportsReferenceCountedRelease = true; foreach (ILogMessageHandler targetLMH in targetLMHArray) { logGate.MesgTypeMask |= targetLMH.LoggerConfig.LogGate.MesgTypeMask; recordSourceStackFrame |= targetLMH.LoggerConfig.RecordSourceStackFrame; supportsReferenceCountedRelease &= targetLMH.LoggerConfig.SupportsReferenceCountedRelease; } loggerConfig.LogGate = logGate; loggerConfig.RecordSourceStackFrame = recordSourceStackFrame; loggerConfig.SupportsReferenceCountedRelease = supportsReferenceCountedRelease; this.targetLMHArray = targetLMHArray; dist = Logging.GetLogMessageDistribution(); mesgDeliveryList = new List<LogMessage>(10); // define its initial capacity mesgQueue = new MessageQueue(maxQueueSize); mesgQueue.SetEffectiveSourceInfo(logger.LoggerSourceInfo); mesgQueue.EnableQueue(); mesgQueueMutex = mesgQueue.Mutex; // create and start the thread StartIfNeeded(); }
/// <summary>Detailed Constructor. Uses given logger name, group name, and initialInstanceLogGate. Use default group name and enables instance trace logging</summary> /// <param name="name">Provides the LoggerName (source ID) to use for this logger.</param> /// <param name="groupName">Provides the GroupName that this logger name will be assigned/moved to</param> /// <param name="initialInstanceLogGate">Defines the initial instance group gate that may be more restrictive than the gate assigned to the group or the logger through the distribution system.</param> /// <param name="callerProvidedLMD">can be used to define the ILogMessageDistribution instance that this object will be used with</param> public QueuedLogger(string name, string groupName, LogGate initialInstanceLogGate, ILogMessageDistribution callerProvidedLMD = null) : base(name, groupName, initialInstanceLogGate, callerProvidedLMD: callerProvidedLMD) { dist4q = callerProvidedLMD ?? Logging.LogMessageDistribution.Instance; if (dist4q == null) { Utils.Asserts.TakeBreakpointAfterFault("{0}: LogMessageDistribution is null".CheckedFormat(ClassName)); } if (dist4q != null) { dist4q.StartQueuedMessageDeliveryIfNeeded(); } }