/// <summary> /// Formats a log list entry. /// </summary> /// <para/> /// If the key is null, writes just the values. /// <param name="entry">Log entry.</param> /// <param name="renderer">Renderer for log data.</param> private void FormatEntry(LogList entry, IDataRenderer renderer) { if (!string.IsNullOrEmpty(entry.Key)) { renderer.RenderKey(entry.Key) .RenderInvariant(KeyValueSeparator); } renderer.RenderInvariant(ListOpening); if (entry.Entries.Count > 0) { foreach (var value in entry.Entries) { if (value is ILogEntry) { FormatEntry((ILogEntry)value, renderer); } else { renderer.RenderValue(value.ToString()); } renderer.RenderInvariant(ListItemSeparator); } renderer.RemoveLastCharacter(); // Removes the last separator. } renderer.RenderInvariant(ListClosing); }
/// <inheritdoc /> public string Format(LogLevelName level, List <ILogEntry> entries, IDataRenderer renderer) { FormatDate(TimeProvider.Now, renderer); FormatLevel(level, renderer); foreach (var entry in entries) { FormatEntry(entry, renderer); renderer.RenderInvariant(EntrySeparator); } renderer.RemoveLastCharacter(); // Removes the last separator. return(renderer.Render()); }
/// <summary> /// Formats a log object entry. /// </summary> /// <para/> /// If the key is null, writes just the values. /// <param name="entry">Log entry.</param> /// <param name="renderer">Renderer for log data.</param> private void FormatEntry(LogObject entry, IDataRenderer renderer) { if (!string.IsNullOrEmpty(entry.Key)) { renderer.RenderKey(entry.Key) .RenderInvariant(KeyValueSeparator); } renderer.RenderInvariant(ObjectOpening); if (entry.Entries.Count > 0) { foreach (var value in entry.Entries) { FormatEntry(value, renderer); renderer.RenderInvariant(EntrySeparator); } renderer.RemoveLastCharacter(); // Removes the last separator. } renderer.RenderInvariant(ObjectClosing); }