/// <summary> /// Use the specified consumer configuration for logging. /// </summary> /// <param name="consumerInfo">The consumer configuration.</param> /// <returns> /// The same <see cref="LogManager" /> instance. /// </returns> public LogManager Use(LogConsumerInfo consumerInfo) { consumerInfo.CheckNotNull(nameof(consumerInfo)); _logConsumers.Add(consumerInfo); return(this); }
/// <summary> /// Specifies the minimum level of the log event to write to the log. /// </summary> /// <typeparam name="TTLogConsumer">The type of the log consumer.</typeparam> /// <param name="builder">The builder.</param> /// <param name="level">The level.</param> /// <returns>The <see cref="AtataContextBuilder{TTLogConsumer}"/> instance.</returns> public static AtataContextBuilder <TTLogConsumer> WithMinLevel <TTLogConsumer>(this AtataContextBuilder <TTLogConsumer> builder, LogLevel level) where TTLogConsumer : ILogConsumer { LogConsumerInfo consumerInfo = builder.BuildingContext.LogConsumers.Single(x => Equals(x.Consumer, builder.Context)); consumerInfo.MinLevel = level; return(builder); }
/// <summary> /// Defines that the logging should not use section-like messages (not "Starting: {action}" and "Finished: {action}", but just "{action}"). /// </summary> /// <typeparam name="TTLogConsumer">The type of the log consumer.</typeparam> /// <param name="builder">The builder.</param> /// <returns>The <see cref="AtataContextBuilder{TTLogConsumer}"/> instance.</returns> public static AtataContextBuilder <TTLogConsumer> WithoutSectionFinish <TTLogConsumer>(this AtataContextBuilder <TTLogConsumer> builder) where TTLogConsumer : ILogConsumer { LogConsumerInfo consumerInfo = builder.BuildingContext.LogConsumers.Single(x => Equals(x.Consumer, builder.Context)); consumerInfo.LogSectionFinish = false; return(builder); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns> /// A new object that is a copy of this instance. /// </returns> public LogConsumerInfo Clone() { LogConsumerInfo clone = (LogConsumerInfo)MemberwiseClone(); if (Consumer is ICloneable cloneableConsumer) { clone.Consumer = (ILogConsumer)cloneableConsumer.Clone(); } return(clone); }
internal LogManager Use(LogConsumerInfo consumerInfo) { logConsumers.Add(consumerInfo); return(this); }
private static string PrependHierarchyPrefixesToMessage(string message, LogEventInfo eventInfo, LogConsumerInfo logConsumerInfo) { StringBuilder builder = new StringBuilder(); if (eventInfo.NestingLevel > 0) { for (int i = 0; i < eventInfo.NestingLevel; i++) { builder.Append(logConsumerInfo.MessageNestingLevelIndent); } } if (logConsumerInfo.LogSectionFinish) { if (eventInfo.SectionStart != null) { builder.Append(logConsumerInfo.MessageStartSectionPrefix); } else if (eventInfo.SectionEnd != null) { builder.Append(logConsumerInfo.MessageEndSectionPrefix); } } string resultMessage = builder.Append(message).ToString(); return(resultMessage.Length == 0 && message == null ? null : resultMessage); }
internal LogManager Use(LogConsumerInfo consumerInfo) { logConsumers.Add(consumerInfo); return this; }