public static IEnumerable <string> FormatFieldValues(LogInspectorEntry item, ILoggingContextFormat format = null) { if (item == null) { yield break; } var timeStamp = item.TimeStamp; yield return(timeStamp.ToString("yyyy-MM-dd")); yield return(timeStamp.ToString("HH:mm:ss")); yield return(item.Level.ToString()); yield return(item.LoggerName); yield return(item.Message); yield return(item.Exception?.ToString() ?? string.Empty); foreach (var value in FormatContextFields(item.Context, format)) { yield return(value); } }
private static IEnumerable <string> FormatContextFields( [CanBeNull] object context, [CanBeNull] ILoggingContextFormat format) { if (context is ILoggingContext ctx) { return(format != null ? format.FormatContextFields(ctx) : ctx.Select(obj => obj.ToString())); } return(Enumerable.Empty <string>()); }
public static IEnumerable <string> FormatFieldHeaders(ILoggingContextFormat format = null) { yield return("Date"); yield return("Time"); yield return("Level"); yield return("Logger"); yield return("Message"); yield return("Exception"); if (format?.ContextHeaders != null) { foreach (var contextHeader in format.ContextHeaders) { yield return(contextHeader); } } }