Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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 Critical(this ILogger source, Action <LogEntryBuilder> action)
        {
            var builder = new LogEntryBuilder().Level(LogLevel.Critical);

            action(builder);

            if (!builder.HasStackTrace)
            {
                var trace = StackTraceExtensions.GetCallerStack();
                builder.WithStackTrace(trace);
            }
            ;

            var entry = builder.ToLogEntry();

            source.LogEntry(entry);

            return(entry.Id);
        }