本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例15: IgnoreSonarScannerHome
private static void IgnoreSonarScannerHome(ILogger logger)
{
if (!String.IsNullOrWhiteSpace(
Environment.GetEnvironmentVariable(SonarScannerHomeVariableName)))
{
logger.LogInfo(Resources.MSG_SonarScannerHomeIsSet);
Environment.SetEnvironmentVariable(SonarScannerHomeVariableName, String.Empty);
}
}