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


C# ILogger.LogVerbose方法代码示例

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


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

示例1: Route

 public static void Route(ILogger logger, string msg)
 {
     if (!msg.IsNullOrEmpty())
     {
         if (msg.StartsWith(StartVerbose))
             _isVerboseMode = true;
         else if (msg.StartsWith(StopVerbose))
             _isVerboseMode = false;
         else
         {
             if (msg.StartsWith(Verbose))
                 logger.LogVerbose(msg.Substring(Verbose.Length));
             else if (msg.StartsWith(Success))
                 logger.LogSuccess(msg.Substring(Success.Length));
             else if (msg.StartsWith(Warning))
                 logger.LogWarning(msg.Substring(Warning.Length));
             else if (msg.StartsWith(Error))
                 logger.LogError(msg.Substring(Error.Length));
             else if (msg.StartsWith(Header))
             {
                 _isVerboseMode = false;
                 logger.LogHeader(msg.Substring(Header.Length));
             }
             else if (_isVerboseMode)
                 logger.LogVerbose(msg);
             else
                 logger.LogInfo(msg);
         }
     }
     else
     {
         //logger.LogInfo(msg);
     }
 }
开发者ID:mdavid626,项目名称:triton,代码行数:34,代码来源:LogRouter.cs

示例2: Match

        public static bool Match(IReadOnlyDictionary<string, IRouteConstraint> constraints,
                                 IDictionary<string, object> routeValues,
                                 HttpContext httpContext,
                                 IRouter route,
                                 RouteDirection routeDirection,
                                 ILogger logger)
        {
            if (routeValues == null)
            {
                throw new ArgumentNullException(nameof(routeValues));
            }

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

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

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

            if (constraints == null)
            {
                return true;
            }

            foreach (var kvp in constraints)
            {
                var constraint = kvp.Value;
                if (!constraint.Match(httpContext, route, kvp.Key, routeValues, routeDirection))
                {
                    if (routeDirection.Equals(RouteDirection.IncomingRequest))
                    {
                        object routeValue;
                        routeValues.TryGetValue(kvp.Key, out routeValue);

                        logger.LogVerbose(
                            "Route value '{RouteValue}' with key '{RouteKey}' did not match " +
                            "the constraint '{RouteConstraint}'.",
                            routeValue,
                            kvp.Key,
                            kvp.Value);
                    }

                    return false;
                }
            }

            return true;
        }
开发者ID:qiudesong,项目名称:Routing,代码行数:56,代码来源:RouteConstraintMatcher.cs

示例3: Configure

        public static void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            logger = loggerFactory.CreateLogger("main");
            logger.LogVerbose("Configure");

            app.UseWebSockets(new WebSocketOptions() { ReplaceFeature = true });

            app.Use(async (context, next) =>
            {
                if (context.WebSockets.IsWebSocketRequest) await InitConnection(context);
                else await next();
            });
        }
开发者ID:streamcode9,项目名称:chat,代码行数:13,代码来源:WebSocketsHelper.cs

示例4: Configure

        public static void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IConfigurationRoot config)
        {
            logger = loggerFactory.CreateLogger("BaseHub");

            logger.LogVerbose("Configure");

            if (_dal == null)
            {
                var hostName = config["Data:DbConnection:Hostname"];
                var dbName = config["Data:DbConnection:DbName"];
                _dal = new BaseDAL(hostName, dbName);
                var connectionRetult = _dal.InitConnection();
                logger.LogVerbose("connectionRetult=" + connectionRetult);
            }

            app.UseWebSockets(new WebSocketOptions() { ReplaceFeature = true });
            app.Use(async (context, next) =>
            {
                if (context.WebSockets.IsWebSocketRequest) await InitConnection(context);
                else await next();
            });
        }
开发者ID:streamcode9,项目名称:MicroCMS,代码行数:22,代码来源:BaseHub.cs

示例5: GetAsync

        public static async Task<HttpResponseMessage> GetAsync(this HttpClient httpClient, string requestUri,
            ILogger logger)
        {
            if (logger == null)
            {
                return await httpClient.GetAsync(requestUri);
            }

            logger.LogVerbose($"Sending request {requestUri}");
            var now = DateTimeOffset.Now;
            var res = await httpClient.GetAsync(requestUri).ConfigureAwait(false);
            if (res.IsSuccessStatusCode)
            {
                logger.LogVerbose(
                    $"Got response {res.StatusCode} in {(DateTimeOffset.Now - now).TotalMilliseconds.ToString("F2")}ms");
            }
            else
            {
                logger.LogError(
                    $"Got response {res.StatusCode} in {(DateTimeOffset.Now - now).TotalMilliseconds.ToString("F2")}ms");
            }
            return res;
        }
开发者ID:lianzhao,项目名称:wiki2dict,代码行数:23,代码来源:HttpClientExtensions.cs

示例6: FromBytes

        public static RedisMessage FromBytes(byte[] data, ILogger logger)
        {
            using (var stream = new MemoryStream(data))
            {
                var message = new RedisMessage();

                // read message id from memory stream until SPACE character
                var messageIdBuilder = new StringBuilder(20);
                do
                {
                    // it is safe to read digits as bytes because they encoded by single byte in UTF-8
                    int charCode = stream.ReadByte();
                    if (charCode == -1)
                    {
                        logger.LogVerbose("Received Message could not be parsed.");
                        throw new EndOfStreamException();
                    }
                    char c = (char)charCode;
                    if (c == ' ')
                    {
                        message.Id = ulong.Parse(messageIdBuilder.ToString(), CultureInfo.InvariantCulture);
                        messageIdBuilder = null;
                    }
                    else
                    {
                        messageIdBuilder.Append(c);
                    }
                }
                while (messageIdBuilder != null);

                var binaryReader = new BinaryReader(stream);
                int count = binaryReader.ReadInt32();
                byte[] buffer = binaryReader.ReadBytes(count);

                message.ScaleoutMessage = ScaleoutMessage.FromBytes(buffer);
                return message;
            }
        }
开发者ID:qiudesong,项目名称:SignalR-Redis,代码行数:38,代码来源:RedisMessage.cs

示例7: Main

        public int Main(string[] args)
        {
#if DEBUG
            if (args.Contains("--debug"))
            {
                args = args.Skip(1).ToArray();
                System.Diagnostics.Debugger.Launch();
            }
#endif

            // Set up logging
            _log = new CommandOutputLogger();

            var app = new CommandLineApplication();
            app.Name = "nuget3";
            app.FullName = ".NET Package Manager";
            app.HelpOption("-h|--help");
            app.VersionOption("--version", GetType().GetTypeInfo().Assembly.GetName().Version.ToString());

            app.Command("restore", restore =>
                {
                    restore.Description = "Restores packages for a project and writes a lock file";

                    var sources = restore.Option("-s|--source <source>", "Specifies a NuGet package source to use during the restore", CommandOptionType.MultipleValue);
                    var packagesDirectory = restore.Option("--packages <packagesDirectory>", "Directory to install packages in", CommandOptionType.SingleValue);
                    var parallel = restore.Option("-p|--parallel <noneOrNumberOfParallelTasks>", $"The number of concurrent tasks to use when restoring. Defaults to {RestoreRequest.DefaultDegreeOfConcurrency}; pass 'none' to run without concurrency.", CommandOptionType.SingleValue);
                    var projectFile = restore.Argument("[project file]", "The path to the project to restore for, either a project.json or the directory containing it. Defaults to the current directory");

                    restore.OnExecute(async () =>
                        {
                            // Figure out the project directory
                            IEnumerable<string> externalProjects = null;

                            PackageSpec project;
                            var projectPath = Path.GetFullPath(projectFile.Value ?? ".");
                            if (string.Equals(PackageSpec.PackageSpecFileName, Path.GetFileName(projectPath), StringComparison.OrdinalIgnoreCase))
                            {
                                _log.LogVerbose($"Reading project file {projectFile.Value}");
                                projectPath = Path.GetDirectoryName(projectPath);
                                project = JsonPackageSpecReader.GetPackageSpec(File.ReadAllText(projectFile.Value), Path.GetFileName(projectPath), projectFile.Value);
                            }
                            else if (MsBuildUtility.IsMsBuildBasedProject(projectPath))
                            {
#if DNXCORE50
                                throw new NotSupportedException();
#else
                                externalProjects = MsBuildUtility.GetProjectReferences(projectPath);

                                projectPath = Path.GetDirectoryName(Path.GetFullPath(projectPath));
                                var packageSpecFile = Path.Combine(projectPath, PackageSpec.PackageSpecFileName);
                                project = JsonPackageSpecReader.GetPackageSpec(File.ReadAllText(packageSpecFile), Path.GetFileName(projectPath), projectFile.Value);
                                _log.LogVerbose($"Reading project file {projectFile.Value}");
#endif
                            }
                            else
                            {
                                var file = Path.Combine(projectPath, PackageSpec.PackageSpecFileName);

                                _log.LogVerbose($"Reading project file {file}");
                                project = JsonPackageSpecReader.GetPackageSpec(File.ReadAllText(file), Path.GetFileName(projectPath), file);
                            }
                            _log.LogVerbose($"Loaded project {project.Name} from {project.FilePath}");

                            // Resolve the root directory
                            var rootDirectory = PackageSpecResolver.ResolveRootDirectory(projectPath);
                            _log.LogVerbose($"Found project root directory: {rootDirectory}");

                            // Resolve the packages directory
                            var packagesDir = packagesDirectory.HasValue() ?
                                packagesDirectory.Value() :
                                Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), ".nuget", "packages");
                            _log.LogVerbose($"Using packages directory: {packagesDir}");

                            var packageSources = sources.Values.Select(s => new PackageSource(s));
                            if (!packageSources.Any())
                            {
                                var settings = Settings.LoadDefaultSettings(projectPath,
                                    configFileName: null,
                                    machineWideSettings: null);
                                var packageSourceProvider = new PackageSourceProvider(settings);
                                packageSources = packageSourceProvider.LoadPackageSources();
                            }

                            var request = new RestoreRequest(
                                project,
                                packageSources,
                                packagesDir);

                            if (externalProjects != null)
                            {
                                foreach (var externalReference in externalProjects)
                                {
                                    request.ExternalProjects.Add(
                                        new ExternalProjectReference(
                                            externalReference,
                                            Path.Combine(Path.GetDirectoryName(externalReference), PackageSpec.PackageSpecFileName),
                                            projectReferences: Enumerable.Empty<string>()));
                                }
                            }

//.........这里部分代码省略.........
开发者ID:eerhardt,项目名称:NuGet3,代码行数:101,代码来源:Program.cs

示例8: ShouldDisplayErrorPage

        private static bool ShouldDisplayErrorPage(DataStoreErrorLogger.DataStoreErrorLog lastError, Exception exception, ILogger logger)
        {
            logger.LogVerbose(Strings.FormatDatabaseErrorPage_AttemptingToMatchException(exception.GetType()));

            if (!lastError.IsErrorLogged)
            {
                logger.LogVerbose(Strings.DatabaseErrorPage_NoRecordedException);
                return false;
            }

            bool match = false;
            for (var e = exception; e != null && !match; e = e.InnerException)
            {
                match = lastError.Exception == e;
            }

            if (!match)
            {
                logger.LogVerbose(Strings.DatabaseErrorPage_NoMatch);
                return false;
            }

            logger.LogVerbose(Strings.DatabaseErrorPage_Matched);
            return true;
        }
开发者ID:knnithyanand,项目名称:Diagnostics,代码行数:25,代码来源:DatabaseErrorPageMiddleware.cs

示例9: Configure

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
      log("Configure");
      loggerFactory.AddConsole(Configuration.GetSection("Logging"));
      loggerFactory.AddDebug();
      _logger = loggerFactory.CreateLogger("mw5");
      _logger.LogInformation("DataFolder = " + _DataFolder);

      app.UseIISPlatformHandler();


      // Register a simple error handler to catch token expiries and change them to a 401, 
      // and return all other errors as a 500. This should almost certainly be improved for
      // a real application.
      app.UseExceptionHandler(appBuilder =>
      {
        appBuilder.Use(async (context, next) =>
          {
            var error = context.Features[typeof(IExceptionHandlerFeature)] as IExceptionHandlerFeature;
            // This should be much more intelligent - at the moment only expired 
            // security tokens are caught - might be worth checking other possible 
            // exceptions such as an invalid signature.
            if (error != null && error.Error is SecurityTokenExpiredException)
            {
              context.Response.StatusCode = 401;
              // What you choose to return here is up to you, in this case a simple 
              // bit of JSON to say you're no longer authenticated.
              context.Response.ContentType = "application/json";
              await context.Response.WriteAsync(
                        JsonConvert.SerializeObject(
                            new { authenticated = false, tokenExpired = true }));
            }
            else if (error != null && error.Error != null)
            {
              context.Response.StatusCode = 500;
              context.Response.ContentType = "application/json";
              // TODO: Shouldn't pass the exception message straight out, change this.
              await context.Response.WriteAsync(
                  JsonConvert.SerializeObject
                  (new { success = false, error = error.Error.Message }));
            }
            // We're not trying to handle anything else so just let the default 
            // handler handle.
            else await next();
          });
      });


      app.UseStaticFiles();

      app.UseMvc();

      bool CreateInitialData = false;
      if (CreateInitialData)
      {
        _logger.LogVerbose("start creating initial data");
        SampleData sd = new SampleData(_logger);
        sd.Initialize(app.ApplicationServices);
        _logger.LogVerbose("initial data created");
      }


    }
开发者ID:gerry123,项目名称:g42,代码行数:64,代码来源:Startup.cs

示例10: LoadTemplate

 public static ReportTemplate LoadTemplate(ReportType reportType, ILogger logger)
 {
     logger.LogVerbose(Message.Common_DebugCall);
     const string REPORTTEMPLATE_FILEPATH_FORMAT = "./Data/Templates/{0}.xml";
     const string REPORTTEMPLATE_SCHEMA_FILEPATH = "./Data/Schemas/ReportTemplate.xsd";
     const string REPORTTEMPLATE_SCHEMA_URL = "http://localhost/Schemas/SIB2003/ReportTemplate";
     var templatePath = new FileInfo(string.Format(REPORTTEMPLATE_FILEPATH_FORMAT, reportType));
     if (!templatePath.Exists)
     {
         logger.LogError(Message.PrintingReportTemplateNotFound, reportType);
         throw new Exception("Не найден шаблон: " + reportType);
     }
     try
     {
         var doc = new XmlDocument();
         doc.Load(templatePath.FullName);
         var xmlSettings = new XmlReaderSettings();
         xmlSettings.Schemas.Add(REPORTTEMPLATE_SCHEMA_URL, REPORTTEMPLATE_SCHEMA_FILEPATH);
         xmlSettings.ValidationEventHandler +=
             (sender, args) => logger.LogError(
                 Message.PrintingReportTemplateValidationError,
                 args.Exception,
                 reportType);
         var xmlTextReader = new XmlTextReader(doc.InnerXml, XmlNodeType.Document, null);
         var xmlReader = XmlReader.Create(xmlTextReader, xmlSettings);
         var oSerializer = new XmlSerializer(typeof(ReportTemplate), REPORTTEMPLATE_SCHEMA_URL);
         logger.LogVerbose(Message.Common_DebugReturn);
         return (ReportTemplate)oSerializer.Deserialize(xmlReader);
     }
     catch (Exception ex)
     {
         logger.LogError(Message.PrintingLoadReportTemplateFailed, ex, reportType);
         throw;
     }
 }
开发者ID:nico-izo,项目名称:KOIB,代码行数:35,代码来源:ReportTemplate.cs


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