コード例 #1
0
        public static INDLogBuilder Error(this INDLogger logger)
        {
            if (!logger.IsEnabled(NDLogLevel.Error))
            {
                return(NDNullLogBuilder.Instance);
            }

            return(new NDLogBuilder(NDLogLevel.Error, logger));
        }
コード例 #2
0
        public static INDLogBuilder Critical(this INDLogger logger)
        {
            if (!logger.IsEnabled(NDLogLevel.Critical))
            {
                return(NDNullLogBuilder.Instance);
            }

            return(new NDLogBuilder(NDLogLevel.Critical, logger));
        }
コード例 #3
0
        public static INDLogBuilder Info(this INDLogger logger)
        {
            if (!logger.IsEnabled(NDLogLevel.Information))
            {
                return(NDNullLogBuilder.Instance);
            }

            return(new NDLogBuilder(NDLogLevel.Information, logger));
        }
コード例 #4
0
        public static INDLogBuilder Warn(this INDLogger logger)
        {
            if (!logger.IsEnabled(NDLogLevel.Warning))
            {
                return(NDNullLogBuilder.Instance);
            }

            return(new NDLogBuilder(NDLogLevel.Warning, logger));
        }
コード例 #5
0
        public static INDLogBuilder Level(this INDLogger logger, NDLogLevel logLevel)
        {
            if (!logger.IsEnabled(logLevel))
            {
                return(NDNullLogBuilder.Instance);
            }

            return(new NDLogBuilder(logLevel, logger));
        }
コード例 #6
0
        public static void Info <T>(this INDLogger logger, T message, Exception exception, IFormatProvider formatter, params object[] args) where T : class
        {
            if (logger == null)
            {
                throw new ArgumentNullException(logger.ToString());
            }


            logger.Log(NDLogLevel.Information, message, exception, formatter, args);
        }
コード例 #7
0
        public static bool RemoveFactory(string logCategory)
        {
            if (!factorys.ContainsKey(logCategory.ToString()))
            {
                return(false);
            }
            INDLogger logger = factorys[logCategory.ToString()].GetLogger();

            loggerCollection.Remove(logger);
            return(true);
        }
コード例 #8
0
        public static void AddFactory(string logCategory, INDLoggerFactory provider)
        {
            if (factorys.ContainsKey(logCategory))
            {
                throw new ArgumentException("添加重复键值:" + logCategory.ToString());
            }
            factorys.Add(logCategory, provider);
            INDLogger logger = provider.CreateLogger();

            if (logger != null)
            {
                loggerCollection.Add(logger);
            }
        }
コード例 #9
0
        public NDLogBuilder(NDLogLevel logLevel, INDLogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(logger.ToString());
            }

            _logger = logger;
            _data   = new LogData
            {
                LogLevel       = logLevel,
                FormatProvider = CultureInfo.InvariantCulture
            };
        }
コード例 #10
0
 public static void Trace(this INDLogger logger, Exception exception, IFormatProvider formatter)
 {
     Trace(logger, "", exception, formatter, null);
 }
コード例 #11
0
 /// <summary>
 /// Formats and writes a debug log message.
 /// </summary>
 /// <param name="logger">The <see cref="INDLogger"/> to write to.</param>
 /// <param name="eventId">The event id associated with the log.</param>
 /// <param name="exception">The exception to log.</param>
 /// <param name="message">Format string of the log message.</param>
 /// <param name="args">An object array that contains zero or more objects to format.</param>
 public static void Trace <T>(this INDLogger logger, T message, Exception exception, params object[] args) where T : class
 {
     Trace(logger, message, exception, null, args);
 }
コード例 #12
0
 //------------------------------------------DEBUG------------------------------------------//
 /// <summary>
 /// Formats and writes a debug log message.
 /// </summary>
 /// <param name="logger">The <see cref="INDLogger"/> to write to.</param>
 /// <param name="eventId">The event id associated with the log.</param>
 /// <param name="message">Format string of the log message.</param>
 /// <param name="args">An object array that contains zero or more objects to format.</param>
 public static void Debug <T>(this INDLogger logger, T message, params object[] args) where T : class
 {
     Debug(logger, message, null, null, args);
 }
コード例 #13
0
 public static void Critical(this INDLogger logger, Exception exception, IFormatProvider formatter)
 {
     Critical(logger, "", exception, formatter, null);
 }
コード例 #14
0
 //------------------------------------------Error------------------------------------------//
 /// <summary>
 /// Formats and writes a debug log message.
 /// </summary>
 /// <param name="logger">The <see cref="INDLogger"/> to write to.</param>
 /// <param name="eventId">The event id associated with the log.</param>
 /// <param name="message">Format string of the log message.</param>
 /// <param name="args">An object array that contains zero or more objects to format.</param>
 public static void Critical <T>(this INDLogger logger, T message, params object[] args) where T : class
 {
     Critical(logger, message, null, null, args);
 }
コード例 #15
0
 //------------------------------------------Error------------------------------------------//
 /// <summary>
 /// Formats and writes a debug log message.
 /// </summary>
 /// <param name="logger">The <see cref="INDLogger"/> to write to.</param>
 /// <param name="eventId">The event id associated with the log.</param>
 /// <param name="message">Format string of the log message.</param>
 /// <param name="args">An object array that contains zero or more objects to format.</param>
 public static void Error <T>(this INDLogger logger, T message, params object[] args) where T : class
 {
     Error(logger, message, null, null, args);
 }