コード例 #1
0
 public static IDisposable ActionScope(this ILogger logger, ActionDescriptor action)
 {
     return logger.BeginScopeImpl(new ActionLogScope(action));
 }
コード例 #2
0
 public static IDisposable RequestScope(this ILogger logger, HttpContext httpContext)
 {
     return logger.BeginScopeImpl(new HostingLogScope(httpContext));
 }
コード例 #3
0
        //------------------------------------------Scope------------------------------------------//

        /// <summary>
        /// Formats the message and creates a scope.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/> to create the scope in.</param>
        /// <param name="messageFormat">Format string of the scope message.</param>
        /// <param name="args">An object array that contains zero or more objects to format.</param>
        /// <returns>A disposable scope object. Can be null.</returns>
        public static IDisposable BeginScope(
            this ILogger logger,
            string messageFormat,
            params object[] args)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (messageFormat == null)
            {
                throw new ArgumentNullException(nameof(messageFormat));
            }

            return logger.BeginScopeImpl(new FormattedLogValues(messageFormat, args));
        }
コード例 #4
0
 public static IDisposable ViewComponentScope(this ILogger logger, ViewComponentContext context)
 {
     return logger.BeginScopeImpl(new ViewComponentLogScope(context.ViewComponentDescriptor));
 }