public void LoggerTest() { IppConfigurationSection target = new IppConfigurationSection(); // TODO: Initialize to an appropriate value LoggerElement actual = target.Logger; Assert.IsNotNull(actual); }
/// <summary> /// Создаем логгер из конфигурации /// </summary> /// <param name="configuration">Элемент конфигурации логгер</param> /// <returns></returns> private static ILogger CreateLogger(LoggerElement configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } ILogger result; if (String.IsNullOrEmpty(configuration.Type)) { result = new Logger(); } else { result = CreateObject( configuration.Type, type => type.IsAbstract == false && type.IsPublic && type.GetInterface(typeof(ILogger).Name) != null ) as ILogger; } if (result != null) { result.Name = configuration.Name; var attrsToHide = new List <AttributeToHide>(); foreach (var attrsList in configuration .Settings .AttributesListsToHide .OfType <AttributeListElement>() .EmptyIfNull()) { if (attrsList.IsEnabled == false) { continue; } var attrs = attrsList.Attributes.OfType <AttributeFilterElement>().ToList(); attrsToHide.AddRange( attrs.Select(itemElement => new AttributeToHide() { Message = attrsList.MessageForReplace, Name = itemElement.Name, Value = itemElement.Value, SearchType = itemElement.SearchType, Regex = itemElement.Pattern } )); } result.AttributesToHide = attrsToHide.ToArray(); } return(result); }
private double LogAndRemove(LoggerElement element) { double ret = 0; if (element != null) { ret = element.Stop(); Debug.WriteLine("******** Completed: " + element.Indent + element.CodeBlockName + "() took [" + ret + "ms] to execute."); Elements.Remove(element); } else { Debug.WriteLine("******** Oops : Element was not found in the stop watch stack."); } return(ret); }
private void executeLogger(LoggerElement loggerNode) { string logType = loggerNode.getAttribute(AttributeConstants.TYPE).getValue().ToString(); string logValue = loggerNode.getAttribute(AttributeConstants.VALUE).getValue().ToString(); switch (logType) { case "Info": logger.Info(this._AttributeSelector.valueOf(logValue)); break; case "Debug": logger.Debug(this._AttributeSelector.valueOf(logValue)); break; default: break; } }
/// <summary> /// Create a ILoggerCreator, that can create the desired logger, when needed /// </summary> /// <param name="loggerElement">The logger element, that contain the logger provider and configuration data</param> /// <returns>An object of ILoggerCreator</returns> private ILoggerCreator LoadLoggerElement(LoggerElement loggerElement) { ILoggerCreator loggerCreator = null; string[] parameters = loggerElement.Creator.Split(new string[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries); if (parameters.Length == 2) { // Try to load the logger dynamicly loggerCreator = this.LoadAssembly(parameters[0], parameters[1]); } else { // The numbers of parameter in the logger provider is not supported throw new LoggingException("Unable to create a logger base on the parameter '" + loggerElement.Creator + "'. The parameter must contain the classname and assambly name."); } return(loggerCreator); }