コード例 #1
0
ファイル: WebApiStartup.cs プロジェクト: vishal-sharma/Beef
        /// <summary>
        /// Binds (redirects) Beef <see cref="Beef.Diagnostics.Logger"/> to the ASP.NET Core <see cref="Microsoft.Extensions.Logging.ILogger"/>.
        /// </summary>
        /// <param name="logger">The ASP.NET Core <see cref="Microsoft.Extensions.Logging.ILogger"/>.</param>
        /// <param name="args">The Beef <see cref="LoggerArgs"/>.</param>
        /// <remarks>Redirects (binds) the Beef logger to the ASP.NET logger.</remarks>
        public static void BindLogger(ILogger logger, LoggerArgs args)
        {
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(args, nameof(args));

#pragma warning disable CA1062 // Validate arguments of public methods; see Check above.
            switch (args.Type)
#pragma warning restore CA1062
            {
            case LogMessageType.Critical:
                logger.LogCritical(args.ToString());
                break;

            case LogMessageType.Info:
                logger.LogInformation(args.ToString());
                break;

            case LogMessageType.Warning:
                logger.LogWarning(args.ToString());
                break;

            case LogMessageType.Error:
                logger.LogError(args.ToString());
                break;

            case LogMessageType.Debug:
                logger.LogDebug(args.ToString());
                break;

            case LogMessageType.Trace:
                logger.LogTrace(args.ToString());
                break;
            }
        }
コード例 #2
0
ファイル: WebApiStartup.cs プロジェクト: keithlemon/Beef
        /// <summary>
        /// Binds (redirects) Beef <see cref="Beef.Diagnostics.Logger"/> to the ASP.NET Core <see cref="Microsoft.Extensions.Logging.ILogger"/>.
        /// </summary>
        /// <param name="logger">The ASP.NET Core <see cref="Microsoft.Extensions.Logging.ILogger"/>.</param>
        /// <param name="args">The Beef <see cref="LoggerArgs"/>.</param>
        /// <remarks>Redirects (binds) the Beef logger to the ASP.NET logger.</remarks>
        public static void BindLogger(ILogger logger, LoggerArgs args)
        {
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(args, nameof(args));

            switch (args.Type)
            {
            case LogMessageType.Critical:
                logger.LogCritical(args.ToString());
                break;

            case LogMessageType.Info:
                logger.LogInformation(args.ToString());
                break;

            case LogMessageType.Warning:
                logger.LogWarning(args.ToString());
                break;

            case LogMessageType.Error:
                logger.LogError(args.ToString());
                break;

            case LogMessageType.Debug:
                logger.LogDebug(args.ToString());
                break;

            case LogMessageType.Trace:
                logger.LogTrace(args.ToString());
                break;
            }
        }