/// <summary>Logs an error message.</summary> /// <param name="source">The source value.</param> /// <param name="action">The action to configure the log entry.</param> /// <returns>The unique log entry ID.</returns> public static Guid Error(this ILogger source, Action <LogEntryBuilder> action) { var builder = new LogEntryBuilder().Level(LogLevel.Error); action(builder); if (builder.ToLogEntry().StackTrace == null) { var trace = StackTraceExtensions.GetCallerStack(); builder.WithStackTrace(trace); } ; var entry = builder.ToLogEntry(); source.LogEntry(entry); return(entry.Id); }
/// <summary>Logs a warning message.</summary> /// <param name="source">The source value.</param> /// <param name="action">The action to configure the builder.</param> /// <returns>The unique log entry ID.</returns> public static Guid Warning(this ILogger source, Action <LogEntryBuilder> action) { var builder = new LogEntryBuilder().Level(LogLevel.Warning); action(builder); var entry = builder.ToLogEntry(); source.LogEntry(entry); return(entry.Id); }