/// <summary> /// Construct a new Configuration object. /// </summary> /// <param name="logs">Enumeration of one or more LogConfiguration objects.</param> /// <param name="allowLogging">Specification for enabling/disabling ETW logging.</param> public Configuration(IEnumerable <LogConfiguration> logs, AllowEtwLoggingValues allowLogging) { if (!Enum.IsDefined(typeof(AllowEtwLoggingValues), allowLogging)) { throw new ArgumentOutOfRangeException(nameof(allowLogging), "Invalid value for allowing ETW logging."); } if (logs == null) { throw new ArgumentNullException(nameof(logs)); } this.AllowEtwLogging = allowLogging; this.logs = new HashSet <LogConfiguration>(); foreach (var log in logs) { log.Validate(); if (log.Type == LogType.MemoryBuffer) { // TODO: enable named memory logs in LogManager. throw new InvalidConfigurationException("Memory logs are not currently supported."); } if (!this.logs.Add(log)) { throw new InvalidConfigurationException($"Duplicate log {log.Name}, {log.Type} not allowed."); } } if (this.logs.Count == 0) { throw new ArgumentException("No log configurations provided.", nameof(logs)); } this.ApplyEtwLoggingSettings(); }
internal void Merge(Configuration other) { if (other == null) { return; } if (other.AllowEtwLogging != AllowEtwLoggingValues.None) { this.AllowEtwLogging = other.AllowEtwLogging; } foreach (var otherLog in other.logs) { var log = this.logs.FirstOrDefault(l => l.Equals(otherLog)); if (log != null) { this.logs.Remove(log); otherLog.Merge(log); } this.logs.Add(otherLog); } this.ApplyEtwLoggingSettings(); }