示例#1
0
        public static LogBuilder Project(this LogBuilder builder, string projectId)
        {
            if (String.IsNullOrEmpty(projectId))
            {
                return(builder);
            }

            return(builder.Property("project", projectId));
        }
示例#2
0
        public static LogBuilder Organization(this LogBuilder builder, string organizationId)
        {
            if (String.IsNullOrEmpty(organizationId))
            {
                return(builder);
            }

            return(builder.Property("organization", organizationId));
        }
示例#3
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;
        }
示例#4
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);
        }
        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));
        }
示例#6
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;
        }
示例#7
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"));

        }
 public static LogBuilder Project(this LogBuilder builder, string projectId)
 {
     return(builder.Property("project", projectId));
 }
示例#9
0
 public static LogBuilder Organization(this LogBuilder builder, string organizationId)
 {
     return(builder.Property("organization", organizationId));
 }