private static LogBuilder Create(LogLevel logLevel, string callerFilePath) { var logger = GetLogger(callerFilePath); var builder = new LogBuilder(logger, logLevel); return(builder); }
public static LogBuilder Tag(this LogBuilder builder, params string[] tags) { var tagList = builder.LogEventInfo.GetTags(); tagList.AddRange(tags); return(builder); }
public static LogBuilder ContextProperty(this LogBuilder builder, string key, object value) { var contextData = builder.LogEventInfo.GetContextData(); contextData[key] = value; return(builder); }
public static LogBuilder Organization(this LogBuilder builder, string organizationId) { if (String.IsNullOrEmpty(organizationId)) { return(builder); } return(builder.Property("organization", organizationId)); }
public static LogBuilder Project(this LogBuilder builder, string projectId) { if (String.IsNullOrEmpty(projectId)) { return(builder); } return(builder.Property("project", projectId)); }
private static LogBuilder Create(LogLevel logLevel, string callerFilePath) { string name = Path.GetFileNameWithoutExtension(callerFilePath ?? string.Empty); var logger = string.IsNullOrWhiteSpace(name) ? _logger : LogManager.GetLogger(name); var builder = new LogBuilder(logger, logLevel); if (callerFilePath != null) builder.Property("CallerFilePath", callerFilePath); return builder; }
public static LogBuilder MarkUnhandled(this LogBuilder builder, string submissionMethod = null) { var contextData = builder.LogEventInfo.GetContextData(); contextData.MarkAsUnhandledError(); if (!String.IsNullOrEmpty(submissionMethod)) { contextData.SetSubmissionMethod(submissionMethod); } return(builder); }
private static LogBuilder Create(LogLevel logLevel, string callerFilePath) { var logger = GetLogger(callerFilePath); var builder = new LogBuilder(logger, logLevel); if (callerFilePath != null) { builder.Property("CallerFilePath", callerFilePath); } return(builder); }
public static LogBuilder Report(this LogBuilder builder, Action <ErrorBuilder> errorBuilderAction = null) { if (builder.LogEventInfo.Exception != null) { ErrorBuilder exBuilder = builder.LogEventInfo.Exception.ToExceptionless(); if (errorBuilderAction != null) { errorBuilderAction(exBuilder); } exBuilder.Submit(); } return(builder); }
public static LogBuilder Tag(this LogBuilder builder, IEnumerable <string> tags) { var tagList = new List <string>(); if (builder.LogEventInfo.Properties.ContainsKey("tags") && builder.LogEventInfo.Properties["tags"] is List <string> ) { tagList = builder.LogEventInfo.Properties["tags"] as List <string>; } foreach (string tag in tags) { if (!tagList.Any(s => s.Equals(tag, StringComparison.OrdinalIgnoreCase))) { tagList.Add(tag); } } return(builder.Property("tags", tagList)); }
public static LogBuilder Report(this LogBuilder builder, Action <EventBuilder> errorBuilderAction = null) { if (builder.LogEventInfo.Exception != null) { EventBuilder exBuilder = builder.LogEventInfo.Exception.ToExceptionless(); if (errorBuilderAction != null) { errorBuilderAction(exBuilder); } exBuilder.AddObject(builder.LogEventInfo, name: "Log Info", excludedPropertyNames: new List <string> { "Exception", "Message", "LoggerShortName", "SequenceID", "TimeStamp" }); exBuilder.Submit(); } return(builder); }
public static LogBuilder Error(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Error); return builder; }
public static LogBuilder Info(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Info); return(builder); }
public static LogBuilder Trace(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Trace); return(builder); }
public static LogBuilder Debug(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Debug); return(builder); }
public static LogBuilder Critical(this LogBuilder builder, bool isCritical = true) { return(isCritical ? builder.Tag(Event.KnownTags.Critical) : builder); }
public static LogBuilder Log(this ILogger logger, LogLevel logLevel) { var builder = new LogBuilder(logger, logLevel); return(builder); }
public static LogBuilder Warn(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Warn); return(builder); }
public static LogBuilder Error(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Error); return(builder); }
public static LogBuilder Project(this LogBuilder builder, string projectId) { return(builder.Property("project", projectId)); }
public static LogBuilder Organization(this LogBuilder builder, string organizationId) { return(builder.Property("organization", organizationId)); }
public static LogBuilder Info(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Info); return builder; }
public static LogBuilder Trace(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Trace); return builder; }
public static LogBuilder Critical(this LogBuilder builder, bool isCritical = true) { return(isCritical ? builder.Tag("Critical") : builder); }
public static LogBuilder Fatal(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Fatal); return builder; }
public static LogBuilder Fatal(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Fatal); return(builder); }
public static LogBuilder Log(this ILogger logger, LogLevel logLevel) { var builder = new LogBuilder(logger, logLevel); return builder; }
public static LogBuilder Tag(this LogBuilder builder, string tag) { return(builder.Tag(new[] { tag })); }
public static LogBuilder Debug(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Debug); return builder; }
public void LogBuilder_null_lead_to_ArgumentNullException() { var logger = LogManager.GetLogger("a"); Assert.Throws<ArgumentNullException>(() => new LogBuilder(null, LogLevel.Debug)); Assert.Throws<ArgumentNullException>(() => new LogBuilder(null)); Assert.Throws<ArgumentNullException>(() => new LogBuilder(logger, null)); var logBuilder = new LogBuilder(logger); Assert.Throws<ArgumentNullException>(() => logBuilder.Properties(null)); Assert.Throws<ArgumentNullException>(() => logBuilder.Property(null, "b")); }
public static LogBuilder Warn(this ILogger logger) { var builder = new LogBuilder(logger, LogLevel.Warn); return builder; }
public void LogBuilder_nLogEventInfo() { var d = new DateTime(2015, 01, 30, 14, 30, 5); var logEventInfo = new LogBuilder(LogManager.GetLogger("a")).LoggerName("b").Level(LogLevel.Fatal).TimeStamp(d).LogEventInfo; Assert.Equal("b", logEventInfo.LoggerName); Assert.Equal(LogLevel.Fatal, logEventInfo.Level); Assert.Equal(d, logEventInfo.TimeStamp); }