当前位置: 首页>>代码示例>>C#>>正文


C# ILogger.IsEnabled方法代码示例

本文整理汇总了C#中ILogger.IsEnabled方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.IsEnabled方法的具体用法?C# ILogger.IsEnabled怎么用?C# ILogger.IsEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILogger的用法示例。


在下文中一共展示了ILogger.IsEnabled方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefaultTypeConvertibleService

 public DefaultTypeConvertibleService(IEnumerable<ITypeConvertibleProvider> providers, ILogger<DefaultTypeConvertibleService> logger)
 {
     _logger = logger;
     providers = providers.ToArray();
     if (_logger.IsEnabled(LogLevel.Debug))
         _logger.Debug($"发现了以下类型转换提供程序:{string.Join(",", providers.Select(p => p.ToString()))}。");
     _converters = providers.SelectMany(p => p.GetConverters()).ToArray();
 }
开发者ID:xiongeee,项目名称:Rpc,代码行数:8,代码来源:DefaultTypeConvertibleService.cs

示例2: FilteredLog

        private static void FilteredLog(ILogger logger, LogLevel level, string message, Exception exception = null, Customer customer = null)
        {
            //don't log thread abort exception
            if (exception is System.Threading.ThreadAbortException)
                return;

            if (logger.IsEnabled(level))
            {
                string fullMessage = exception == null ? string.Empty : exception.ToString();
                logger.InsertLog(level, message, fullMessage, customer);
            }
        }
开发者ID:RobinHoody,项目名称:nopCommerce,代码行数:12,代码来源:LoggingExtensions.cs

示例3: FilteredLog

        private static void FilteredLog(ILogger logger, LogLevel level, string message, Exception exception = null,
            User user = null)
        {
            //No se guarda el registro cuando es de un hilo de una excepcion de abort
            if (exception is ThreadAbortException)
                return;

            if (logger.IsEnabled(level))
            {
                var fullMessage = exception == null ? string.Empty : exception.ToString();
                logger.InsertLog(level, message, fullMessage, user);
            }
        }
开发者ID:pcurich,项目名称:ViccosLite,代码行数:13,代码来源:LoggingExtensions.cs

示例4: FilteredLog

 private static void FilteredLog(ILogger logger, LogLevel level, string message,
     Exception exception = null, Customer customer = null, bool stopException = true)
 {
     // không log thông điệp khi ngoại lệ là ThreadAbortException
     if (exception is ThreadAbortException) return;
     try
     {
         if (logger.IsEnabled(level)) // nếu cho phép ghi log với kiểu level
         {
             string fullMessage = exception == null ? string.Empty : exception.ToString();
             logger.InsertLog(level, message, fullMessage, customer);
         }
     }
     catch (Exception)
     {
         if (!stopException) throw;
     }
 }
开发者ID:sounj142,项目名称:NopResearch,代码行数:18,代码来源:LoggingExtensions.cs

示例5: FilteredLog

 private static void FilteredLog(ILogger logger, LogLevel level, Exception exception, string format, object[] objects) {
     if (logger.IsEnabled(level)) {
         logger.Log(level, exception, format, objects);
     }
 }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:5,代码来源:LoggingExtensions.cs

示例6: ExecuteAsync

        public override async Task ExecuteAsync(
            IRelationalConnection connection,
            ILogger logger,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(logger, nameof(logger));

            var commandText = GetCommandText();

            using (var storeCommand = CreateStoreCommand(commandText, connection))
            {
                if (logger.IsEnabled(LogLevel.Verbose))
                {
                    logger.LogCommand(storeCommand);
                }

                try
                {
                    using (var reader = await storeCommand.ExecuteReaderAsync(cancellationToken))
                    {
                        await ConsumeAsync(reader, cancellationToken);
                    }
                }
                catch (DbUpdateException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new DbUpdateException(RelationalStrings.UpdateStoreException, ex);
                }
            }
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:34,代码来源:ReaderModificationCommandBatch.cs

示例7: Execute

        public override void Execute(
            IRelationalConnection connection,
            ILogger logger)
        {
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(logger, nameof(logger));

            var commandText = GetCommandText();

            using (var storeCommand = CreateStoreCommand(commandText, connection))
            {
                if (logger.IsEnabled(LogLevel.Verbose))
                {
                    logger.LogCommand(storeCommand);
                }

                try
                {
                    using (var reader = storeCommand.ExecuteReader())
                    {
                        Consume(reader);
                    }
                }
                catch (DbUpdateException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new DbUpdateException(RelationalStrings.UpdateStoreException, ex);
                }
            }
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:33,代码来源:ReaderModificationCommandBatch.cs

示例8: IsLogLevelEnabledCore

 private static bool IsLogLevelEnabledCore(ILogger logger, LogLevel level)
 {
     return (logger != null && logger.IsEnabled(level));
 }
开发者ID:leloulight,项目名称:DataProtection,代码行数:4,代码来源:LoggingExtensions.cs

示例9: ExecuteAsync

        public override async Task<int> ExecuteAsync(
            RelationalTransaction transaction,
            RelationalTypeMapper typeMapper,
            DbContext context,
            ILogger logger,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            Check.NotNull(transaction, nameof(transaction));
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(context, nameof(context));
            Check.NotNull(logger, nameof(logger));

            var commandText = GetCommandText();

            Debug.Assert(ResultSetEnds.Count == ModificationCommands.Count);

            var commandIndex = 0;
            using (var storeCommand = CreateStoreCommand(commandText, transaction.DbTransaction, typeMapper, transaction.Connection?.CommandTimeout))
            {
                if (logger.IsEnabled(LogLevel.Verbose))
                {
                    logger.LogCommand(storeCommand);
                }

                try
                {
                    using (var reader = await storeCommand.ExecuteReaderAsync(cancellationToken).WithCurrentCulture())
                    {
                        var actualResultSetCount = 0;
                        do
                        {
                            commandIndex = ModificationCommands[commandIndex].RequiresResultPropagation
                                ? await ConsumeResultSetWithPropagationAsync(commandIndex, reader, context, cancellationToken)
                                    .WithCurrentCulture()
                                : await ConsumeResultSetWithoutPropagationAsync(commandIndex, reader, context, cancellationToken)
                                    .WithCurrentCulture();
                            actualResultSetCount++;
                        }
                        while (commandIndex < ResultSetEnds.Count
                               && await reader.NextResultAsync(cancellationToken).WithCurrentCulture());

                        Debug.Assert(commandIndex == ModificationCommands.Count, "Expected " + ModificationCommands.Count + " results, got " + commandIndex);
#if DEBUG
                        var expectedResultSetCount = 1 + ResultSetEnds.Count(e => e);
                        expectedResultSetCount += ResultSetEnds[ResultSetEnds.Count - 1] ? -1 : 0;

                        Debug.Assert(actualResultSetCount == expectedResultSetCount, "Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount);
#endif
                    }
                }
                catch (DbUpdateException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new DbUpdateException(
                        Strings.UpdateStoreException,
                        context,
                        ex,
                        commandIndex < ModificationCommands.Count ? ModificationCommands[commandIndex].Entries : new InternalEntityEntry[0]);
                }
            }

            return commandIndex;
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:66,代码来源:ReaderModificationCommandBatch.cs

示例10: FilteredLog

 private static void FilteredLog(ILogger logger, LogLevel level, Exception exception, Func<string> message)
 {
     if (logger.IsEnabled(level))
         logger.Log(level, exception, message == null ? null : message());
 }
开发者ID:l1183479157,项目名称:RabbitHub,代码行数:5,代码来源:LoggingExtensions.cs

示例11: FilteredLog

 private static void FilteredLog(ILogger logger, LogLevel level, string category, string format, object[] objects)
 {
     if (logger.IsEnabled(level))
     {
         logger.Log(level, category, format, objects);
     }
 }
开发者ID:Kendry06,项目名称:Gymnastika,代码行数:7,代码来源:LoggerExtensions.cs


注:本文中的ILogger.IsEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。