예제 #1
0
        private static LogBuilder Create(LogLevel logLevel, string callerFilePath)
        {
            var logger  = GetLogger(callerFilePath);
            var builder = new LogBuilder(logger, logLevel);

            return(builder);
        }
예제 #2
0
        public static LogBuilder Tag(this LogBuilder builder, params string[] tags)
        {
            var tagList = builder.LogEventInfo.GetTags();

            tagList.AddRange(tags);

            return(builder);
        }
예제 #3
0
        public static LogBuilder ContextProperty(this LogBuilder builder, string key, object value)
        {
            var contextData = builder.LogEventInfo.GetContextData();

            contextData[key] = value;

            return(builder);
        }
예제 #4
0
        public static LogBuilder Organization(this LogBuilder builder, string organizationId)
        {
            if (String.IsNullOrEmpty(organizationId))
            {
                return(builder);
            }

            return(builder.Property("organization", organizationId));
        }
예제 #5
0
        public static LogBuilder Project(this LogBuilder builder, string projectId)
        {
            if (String.IsNullOrEmpty(projectId))
            {
                return(builder);
            }

            return(builder.Property("project", projectId));
        }
예제 #6
0
파일: Log.cs 프로젝트: zuohu/NLog
        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;
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #12
0
 public static LogBuilder Error(this ILogger logger)
 {
     var builder = new LogBuilder(logger, LogLevel.Error);
     return builder;
 }
예제 #13
0
        public static LogBuilder Info(this ILogger logger)
        {
            var builder = new LogBuilder(logger, LogLevel.Info);

            return(builder);
        }
예제 #14
0
파일: Log.cs 프로젝트: CharlieBP/NLog
        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;
        }
예제 #15
0
        public static LogBuilder Trace(this ILogger logger)
        {
            var builder = new LogBuilder(logger, LogLevel.Trace);

            return(builder);
        }
예제 #16
0
        public static LogBuilder Debug(this ILogger logger)
        {
            var builder = new LogBuilder(logger, LogLevel.Debug);

            return(builder);
        }
예제 #17
0
 public static LogBuilder Critical(this LogBuilder builder, bool isCritical = true)
 {
     return(isCritical ? builder.Tag(Event.KnownTags.Critical) : builder);
 }
예제 #18
0
        public static LogBuilder Log(this ILogger logger, LogLevel logLevel)
        {
            var builder = new LogBuilder(logger, logLevel);

            return(builder);
        }
예제 #19
0
        public static LogBuilder Warn(this ILogger logger)
        {
            var builder = new LogBuilder(logger, LogLevel.Warn);

            return(builder);
        }
예제 #20
0
        public static LogBuilder Error(this ILogger logger)
        {
            var builder = new LogBuilder(logger, LogLevel.Error);

            return(builder);
        }
예제 #21
0
 public static LogBuilder Project(this LogBuilder builder, string projectId)
 {
     return(builder.Property("project", projectId));
 }
예제 #22
0
 public static LogBuilder Organization(this LogBuilder builder, string organizationId)
 {
     return(builder.Property("organization", organizationId));
 }
예제 #23
0
 public static LogBuilder Info(this ILogger logger)
 {
     var builder = new LogBuilder(logger, LogLevel.Info);
     return builder;
 }
예제 #24
0
 public static LogBuilder Trace(this ILogger logger)
 {
     var builder = new LogBuilder(logger, LogLevel.Trace);
     return builder;
 }
예제 #25
0
 public static LogBuilder Critical(this LogBuilder builder, bool isCritical = true)
 {
     return(isCritical ? builder.Tag("Critical") : builder);
 }
예제 #26
0
 public static LogBuilder Fatal(this ILogger logger)
 {
     var builder = new LogBuilder(logger, LogLevel.Fatal);
     return builder;
 }
예제 #27
0
        public static LogBuilder Fatal(this ILogger logger)
        {
            var builder = new LogBuilder(logger, LogLevel.Fatal);

            return(builder);
        }
예제 #28
0
 public static LogBuilder Log(this ILogger logger, LogLevel logLevel)
 {
     var builder = new LogBuilder(logger, logLevel);
     return builder;
 }
예제 #29
0
 public static LogBuilder Tag(this LogBuilder builder, string tag)
 {
     return(builder.Tag(new[] { tag }));
 }
예제 #30
0
 public static LogBuilder Debug(this ILogger logger)
 {
     var builder = new LogBuilder(logger, LogLevel.Debug);
     return builder;
 }
예제 #31
0
        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"));

        }
예제 #32
0
 public static LogBuilder Warn(this ILogger logger)
 {
     var builder = new LogBuilder(logger, LogLevel.Warn);
     return builder;
 }
예제 #33
0
        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);
        }