/// <summary> /// Gets all the log sink instances of a profile. /// </summary> /// <param name="profileName">The name of the profile.</param> /// <param name="kind">The log kind which the result sinks associated with.</param> /// <returns>A list which contains the log sinks.</returns> internal List <LogSink> GetSinksOfProfile(string profileName, LogEntryKind kind) { List <LogSink> sinks = new List <LogSink>(); // Gets specified profile information. Dictionary <string, List <LogEntryKind> > profile = profilesMap[profileName]; // Scans all sinks associated with the profile. foreach (string sinkName in profile.Keys) { // Retrieves the sink instance by name. LogSink sink = allSinks[sinkName]; // Check if this log entry kind can be accepted by this sink. if (profile[sinkName].Contains(kind)) { sinks.Add(sink); } } return(sinks); }
/// <summary> /// Adds a named log sink to the current logging profiles context. /// </summary> /// <param name="logSinkName">The name of the sink</param> /// <param name="sink">An instance of LogSink.</param> public void AddSink(string logSinkName, LogSink sink) { if (allSinks.ContainsKey(logSinkName)) { throw new InvalidOperationException(String.Format("The log sink {0} already exists.", logSinkName)); } allSinks.Add(logSinkName, sink); }