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


C# ILogger.LogInfo方法代码示例

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


在下文中一共展示了ILogger.LogInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ExecuteJavaRunner

        /* for test purposes */
        public static bool ExecuteJavaRunner(AnalysisConfig config, IEnumerable<string> userCmdLineArguments, ILogger logger, string exeFileName, string propertiesFileName)
        {
            Debug.Assert(File.Exists(exeFileName), "The specified exe file does not exist: " + exeFileName);
            Debug.Assert(File.Exists(propertiesFileName), "The specified properties file does not exist: " + propertiesFileName);

            IgnoreSonarRunnerHome(logger);

            IEnumerable<string> allCmdLineArgs = GetAllCmdLineArgs(propertiesFileName, userCmdLineArguments, config);

            IDictionary<string, string> envVarsDictionary = GetAdditionalEnvVariables(logger);
            Debug.Assert(envVarsDictionary != null);

            logger.LogInfo(Resources.MSG_CallingSonarRunner);
            ProcessRunnerArguments runnerArgs = new ProcessRunnerArguments(exeFileName, logger)
            {
                CmdLineArgs = allCmdLineArgs,
                WorkingDirectory = Path.GetDirectoryName(exeFileName),
                EnvironmentVariables = envVarsDictionary
            };
            ProcessRunner runner = new ProcessRunner();

            bool success = runner.Execute(runnerArgs);

            success = success && !runner.ErrorsLogged;

            if (success)
            {
                logger.LogInfo(Resources.MSG_SonarRunnerCompleted);
            }
            else
            {
                logger.LogError(Resources.ERR_SonarRunnerExecutionFailed);
            }
            return success;
        }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:36,代码来源:SonarRunner.Wrapper.cs

示例3: PreProcess

        private static int PreProcess(IBuildAgentUpdater updater, IBootstrapperSettings settings, ILogger logger)
        {
            string downloadBinPath = settings.DownloadDirectory;

            logger.LogInfo(Resources.MSG_PreparingDirectories);
            if (!Utilities.TryEnsureEmptyDirectories(logger,
                settings.TempDirectory,
                downloadBinPath))
            {
                return ErrorCode;
            }

            string server = settings.SonarQubeUrl;
            Debug.Assert(!string.IsNullOrWhiteSpace(server), "Not expecting the server url to be null/empty");
            logger.LogDebug(Resources.MSG_ServerUrl, server);

            logger.LogInfo(Resources.MSG_CheckingForUpdates);
            if (!updater.TryUpdate(server, downloadBinPath, logger))
            {
                logger.LogError(Resources.ERROR_FailedToUpdateRunnerBinaries);
                return ErrorCode;
            }

            if (!updater.CheckBootstrapperApiVersion(settings.SupportedBootstrapperVersionsFilePath, settings.BootstrapperVersion))
            {
                logger.LogError(Resources.ERROR_VersionMismatch);
                return ErrorCode;
            }

            var preprocessorFilePath = settings.PreProcessorFilePath;

            ProcessRunnerArguments runnerArgs = new ProcessRunnerArguments(preprocessorFilePath, logger)
            {
                CmdLineArgs = settings.ChildCmdLineArgs,
                WorkingDirectory = settings.TempDirectory,
            };
            ProcessRunner runner = new ProcessRunner();
            runner.Execute(runnerArgs);

            return runner.ExitCode;
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:41,代码来源:Program.cs

示例4: LogProcessingCompleted

 private static void LogProcessingCompleted(AnalysisPhase phase, int exitCode, ILogger logger)
 {
     string phaseLabel = phase == AnalysisPhase.PreProcessing ? Resources.PhaseLabel_PreProcessing : Resources.PhaseLabel_PostProcessing;
     if (exitCode == ProcessRunner.ErrorCode)
     {
         logger.LogError(Resources.ERROR_ProcessingFailed, phaseLabel, exitCode);
     }
     else
     {
         logger.LogInfo(Resources.MSG_ProcessingSucceeded, phaseLabel);
     }
 }
开发者ID:nilleb,项目名称:sonar-msbuild-runner,代码行数:12,代码来源:Program.cs

示例5: LogAssemblyVersion

        public static void LogAssemblyVersion(Assembly assembly, string description, ILogger logger)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            logger.LogInfo("{0} {1}", description, assembly.GetName().Version);
        }
开发者ID:HSAR,项目名称:sonarqube-roslyn-sdk,代码行数:13,代码来源:Utilities.cs

示例6: OnStart

        protected override void OnStart(string[] args)
        {
            base.OnStart(args);

            var builder = new ContainerBuilder();
            builder.RegisterModule(new TradeReporterModule());
            var container = builder.Build();
            _reporter = container.Resolve<ITradeReportGenerator>();
            _logger = container.Resolve<ILogger>();
            _logger.LogInfo("Service Started");

            _thread = new Thread(RunReport);
            _thread.Start();
        }
开发者ID:neoms21,项目名称:TradeReporter,代码行数:14,代码来源:Service.cs

示例7: InternalCopyTargetsFile

        private static void InternalCopyTargetsFile(ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            logger.LogInfo(Resources.MSG_UpdatingMSBuildTargets);

            string sourceTargetsPath = Path.Combine(Path.GetDirectoryName(typeof(TeamBuildPreProcessor).Assembly.Location), "Targets", LoaderTargetsName);
            Debug.Assert(File.Exists(sourceTargetsPath),
                String.Format(System.Globalization.CultureInfo.InvariantCulture, "Could not find the loader .targets file at {0}", sourceTargetsPath));

            CopyIfDifferent(sourceTargetsPath, DestinationDirectories, logger);
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:15,代码来源:TargetsInstaller.cs

示例8: ExecuteJavaRunner

        /* for test purposes */
        public static bool ExecuteJavaRunner(AnalysisConfig config, IEnumerable<string> userCmdLineArguments, ILogger logger, string exeFileName, string propertiesFileName)
        {
            Debug.Assert(File.Exists(exeFileName), "The specified exe file does not exist: " + exeFileName);
            Debug.Assert(File.Exists(propertiesFileName), "The specified properties file does not exist: " + propertiesFileName);

            IgnoreSonarScannerHome(logger);

            IEnumerable<string> allCmdLineArgs = GetAllCmdLineArgs(propertiesFileName, userCmdLineArguments, config);

            IDictionary<string, string> envVarsDictionary = GetAdditionalEnvVariables(logger);
            Debug.Assert(envVarsDictionary != null);

            logger.LogInfo(Resources.MSG_SonarScannerCalling);

            Debug.Assert(!String.IsNullOrWhiteSpace(config.SonarRunnerWorkingDirectory), "The working dir should have been set in the analysis config");
            Debug.Assert(Directory.Exists(config.SonarRunnerWorkingDirectory), "The working dir should exist");

            ProcessRunnerArguments runnerArgs = new ProcessRunnerArguments(exeFileName, logger)
            {
                CmdLineArgs = allCmdLineArgs,
                WorkingDirectory = config.SonarRunnerWorkingDirectory,
                EnvironmentVariables = envVarsDictionary
            };

            ProcessRunner runner = new ProcessRunner();

            // SONARMSBRU-202 Note that the Sonar Scanner may write warnings to stderr so
            // we should only rely on the exit code when deciding if it ran successfully
            bool success = runner.Execute(runnerArgs);

            if (success)
            {
                logger.LogInfo(Resources.MSG_SonarScannerCompleted);
            }
            else
            {
                logger.LogError(Resources.ERR_SonarScannerExecutionFailed);
            }
            return success;
        }
开发者ID:HSAR,项目名称:sonar-msbuild-runner,代码行数:41,代码来源:SonarRunner.Wrapper.cs

示例9: CompileAssembly

        /// <summary>
        /// Compiles the supplied code into a new assembly
        /// </summary>
        private static Assembly CompileAssembly(string code, string outputFilePath, ILogger logger)
        {
            CSharpCodeProvider provider = new CSharpCodeProvider();

            CompilerParameters options = new CompilerParameters();
            options.OutputAssembly = outputFilePath;
            options.GenerateExecutable = true;
            options.GenerateInMemory = false;

            CompilerResults result = provider.CompileAssemblyFromSource(options, code);

            if (result.Errors.Count > 0)
            {
                foreach (string item in result.Output)
                {
                    logger.LogInfo(item);
                }
                Assert.Fail("Test setup error: failed to create dynamic assembly. See the test output for compiler output");
            }

            return result.CompiledAssembly;
        }
开发者ID:p3pijn,项目名称:sonarqube-roslyn-sdk,代码行数:25,代码来源:AssemblyResolverTests.cs

示例10: TryGetBinaryReportFile

        protected override bool TryGetBinaryReportFile(AnalysisConfig config, TeamBuildSettings settings, ILogger logger, out string binaryFilePath)
        {
            IEnumerable<string> urls = this.urlProvider.GetCodeCoverageReportUrls(config.GetTfsUri(), config.GetBuildUri(), logger);
            Debug.Assert(urls != null, "Not expecting the returned list of urls to be null");

            bool continueProcessing = true;
            binaryFilePath = null;

            switch (urls.Count())
            {
                case 0:
                    logger.LogInfo(Resources.PROC_DIAG_NoCodeCoverageReportsFound);
                    break;

                case 1:
                    string url = urls.First();

                    string targetFileName = Path.Combine(config.SonarOutputDir, DownloadFileName);
                    bool result = this.downloader.DownloadReport(config.GetTfsUri(), url, targetFileName, logger);

                    if (result)
                    {
                        binaryFilePath = targetFileName;
                    }
                    else
                    {
                        continueProcessing = false;
                        logger.LogError(Resources.PROC_ERROR_FailedToDownloadReport);
                    }
                    break;

                default: // More than one
                    continueProcessing = false;
                    logger.LogError(Resources.PROC_ERROR_MultipleCodeCoverageReportsFound);
                    break;
            }

            return continueProcessing;
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:39,代码来源:TfsLegacyCoverageReportProcessor.cs

示例11: InternalDownloadReport

        private void InternalDownloadReport(string tfsUri, string reportUrl, string reportDestinationPath, ILogger logger)
        {
            VssHttpMessageHandler vssHttpMessageHandler = GetHttpHandler(tfsUri, logger);

            logger.LogInfo(Resources.DOWN_DIAG_DownloadCoverageReportFromTo, reportUrl, reportDestinationPath);

            using (HttpClient httpClient = new HttpClient(vssHttpMessageHandler))
            using (HttpResponseMessage response = httpClient.GetAsync(reportUrl).Result)
            {
                if (response.IsSuccessStatusCode)
                {
                    using (FileStream fileStream = new FileStream(reportDestinationPath, FileMode.Create, FileAccess.Write))
                    {
                        response.Content.CopyToAsync(fileStream).Wait();
                    }
                }
                else
                {
                    logger.LogError(Resources.PROC_ERROR_FailedToDownloadReportReason, reportUrl, response.StatusCode, response.ReasonPhrase);
                }
            }
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:22,代码来源:CoverageReportDownloader.cs

示例12: GetHttpHandler

        private VssHttpMessageHandler GetHttpHandler(string tfsUri, ILogger logger)
        {
            VssCredentials vssCreds = null;
            Uri tfsCollectionUri = new Uri(tfsUri);

            using (TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsCollectionUri))
            {
                // Build agents run non-attended and most often non-interactive so make sure not to create a credential prompt
                collection.ClientCredentials.AllowInteractive = false;
                collection.EnsureAuthenticated();

                logger.LogInfo(Resources.DOWN_DIAG_ConnectedToTFS, tfsUri);

                // We need VSS credentials that encapsulate all types of credentials (NetworkCredentials for TFS, OAuth for VSO)
                TfsConnection connection = collection as TfsConnection;
                vssCreds = connection.ClientCredentials.ConvertToVssCredentials(tfsCollectionUri);
            }

            Debug.Assert(vssCreds != null, "Not expecting ConvertToVssCredentials ");
            VssHttpMessageHandler vssHttpMessageHandler = new VssHttpMessageHandler(vssCreds, new VssHttpRequestSettings());

            return vssHttpMessageHandler;
        }
开发者ID:BrightLight,项目名称:sonar-msbuild-runner,代码行数:23,代码来源:CoverageReportDownloader.cs

示例13: OnStart

        /// <summary>
        /// Start the service
        /// </summary>
        /// <remarks>This service is not receiving any arguments at the moment</remarks>
        /// <param name="args">Arguments to receive when starting the service</param>
        protected override void OnStart(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            log = LogFactory.GetLogger(typeof(Service));
            log.LogInfo("Service Started.");
            try
            {

                //get service credential details
                if (!string.IsNullOrEmpty(serviceUserName))
                {
                    //Check what is the user for this service. If the user doesn't exist then it should create it.
                    MembershipUser membershipUser = Membership.GetUser(serviceUserName);

                    if (membershipUser == null)
                    {
                        //Could not acquire user.
                        log.LogFatal("Eagle Service cannot acquire user to execute tasks and it is going to stop.");
                        return;
                    }

                    //Add the identity and principal of our internal service user to the current principal
                    Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(membershipUser.ProviderUserKey.ToString()), null);
                    ServiceTaskManager.Initialize();
                }
                else
                {
                    //Could not acquire user.
                    log.LogFatal("Eagle Service cannot acquire user to execute tasks and it is going to stop.");
                }
            }
            catch (Exception e)
            {
                log.LogError("Error on service start", ex: e);
            }
        }
开发者ID:ognjenm,项目名称:egle,代码行数:41,代码来源:Service.cs

示例14: InternalExecute

        private static void InternalExecute(AnalysisConfig config, IEnumerable<string> userCmdLineArguments, ILogger logger, ProjectInfoAnalysisResult result)
        {
            ProjectInfoReportBuilder.WriteSummaryReport(config, result, logger);

            if (result.FullPropertiesFilePath == null)
            {
                // We expect a detailed error message to have been logged explaining
                // why the properties file generation could not be performed
                logger.LogInfo(Resources.MSG_PropertiesGenerationFailed);
            }
            else
            {
                string exeFileName = FindRunnerExe(config, logger);
                if (exeFileName != null)
                {
                    result.RanToCompletion = ExecuteJavaRunner(config, userCmdLineArguments, logger, exeFileName, result.FullPropertiesFilePath);
                }
            }
        }
开发者ID:HSAR,项目名称:sonar-msbuild-runner,代码行数:19,代码来源:SonarRunner.Wrapper.cs

示例15: IgnoreSonarScannerHome

 private static void IgnoreSonarScannerHome(ILogger logger)
 {
     if (!String.IsNullOrWhiteSpace(
         Environment.GetEnvironmentVariable(SonarScannerHomeVariableName)))
     {
         logger.LogInfo(Resources.MSG_SonarScannerHomeIsSet);
         Environment.SetEnvironmentVariable(SonarScannerHomeVariableName, String.Empty);
     }
 }
开发者ID:HSAR,项目名称:sonar-msbuild-runner,代码行数:9,代码来源:SonarRunner.Wrapper.cs


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