本文整理汇总了C#中ILogger.Log方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.Log方法的具体用法?C# ILogger.Log怎么用?C# ILogger.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public bool Execute(string installPath, string scriptFileName, IPackage package, Project project, FrameworkName targetFramework, ILogger logger)
{
string scriptPath, fullPath;
if (package.FindCompatibleToolFiles(scriptFileName, targetFramework, out scriptPath))
{
fullPath = Path.Combine(installPath, scriptPath);
}
else
{
return false;
}
if (File.Exists(fullPath))
{
string toolsPath = Path.GetDirectoryName(fullPath);
string logMessage = String.Format(CultureInfo.CurrentCulture, VsResources.ExecutingScript, fullPath);
// logging to both the Output window and progress window.
logger.Log(MessageLevel.Info, logMessage);
IConsole console = OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: true);
Host.Execute(console,
"[email protected](); $input|%{$__pc_args+=$_}; & " + PathHelper.EscapePSPath(fullPath) + " $__pc_args[0] $__pc_args[1] $__pc_args[2] $__pc_args[3]; Remove-Variable __pc_args -Scope 0",
new object[] { installPath, toolsPath, package, project });
return true;
}
return false;
}
示例2: LogTeamSelection
public static void LogTeamSelection(TeamSelection teamSelection, int gameweek, List<PredictedPlayerScore> predictedPlayerPoints, ILogger logger, bool important = false)
{
logger.Log(Tag.Prediction, string.Format("Selected team for gameweek {0}", gameweek), important);
logger.Log(Tag.Prediction, string.Format("Predicted points: {0}", teamSelection.PredictedTotalTeamScore.ToFormatted()), important);
LogTeamFormation(teamSelection.Team, logger);
for (var i = 0; i < teamSelection.Team.Players.Count; i++)
{
if (i == 11)
{
logger.Log(Tag.Team, "---");
}
var player = teamSelection.Team.Players[i];
var fixtures = player.FutureFixtures.Where(x => x.GameWeek == gameweek);
var extraData = new StringBuilder(" ");
foreach (var fixture in fixtures)
{
extraData.Append(fixture.OppositionClubCode);
extraData.Append(fixture.Home ? "(H) " : "(A) ");
}
var playerGameweekPoints = predictedPlayerPoints.Single(p => p.Player == player).PredictedScore;
extraData.Append(playerGameweekPoints.ToFormatted());
if (teamSelection.Team.Captain == player)
{
extraData.Append("(");
extraData.Append((playerGameweekPoints * 2).ToFormatted());
extraData.Append(")");
}
LogPlayer(player, teamSelection.Team, logger, extraData.ToString(), important);
}
LogTeamCost(teamSelection.Team, logger, important);
}
示例3: ApplyDacpac
public static void ApplyDacpac(Stream dacpac, string connectionString, string databaseName, ILogger log)
{
var options = new DacDeployOptions()
{
BlockOnPossibleDataLoss = true,
IncludeTransactionalScripts = true,
DropConstraintsNotInSource = false,
DropIndexesNotInSource = false,
DropDmlTriggersNotInSource = false,
DropObjectsNotInSource = false,
DropExtendedPropertiesNotInSource = false,
DropPermissionsNotInSource = false,
DropStatisticsNotInSource = false,
DropRoleMembersNotInSource = false,
};
var service = new DacServices(connectionString);
service.Message += (x, y) =>
{
log.Log(y.Message.Message);
};
try
{
using (var package = DacPackage.Load(dacpac))
{
service.Deploy(package, databaseName, true, options);
}
}
catch (Exception e)
{
log.Log(e.Message, true);
}
}
示例4: LogValidationErrors
private static void LogValidationErrors(ILogger logger, Exception exception)
{
//Try to find inner validation exception
if (exception is AggregateException && exception.InnerException != null)
{
var aggException = exception as AggregateException;
if (aggException.InnerException is AbpValidationException)
{
exception = aggException.InnerException;
}
}
if (!(exception is AbpValidationException))
{
return;
}
var validationException = exception as AbpValidationException;
if (validationException.ValidationErrors.IsNullOrEmpty())
{
return;
}
logger.Log(validationException.Severity, "There are " + validationException.ValidationErrors.Count + " validation errors:");
foreach (var validationResult in validationException.ValidationErrors)
{
var memberNames = "";
if (validationResult.MemberNames != null && validationResult.MemberNames.Any())
{
memberNames = " (" + string.Join(", ", validationResult.MemberNames) + ")";
}
logger.Log(validationException.Severity, validationResult.ErrorMessage + memberNames);
}
}
示例5: RemoteConfigManager
public RemoteConfigManager(IResourceLoader loader, IStorage storage, ILogger logger, RuntimePlatform platform)
{
this.storage = storage;
logger.prefix = "Unibill.RemoteConfigManager";
this.XML = loader.openTextFile ("unibillInventory.json").ReadToEnd ();
Config = new UnibillConfiguration(XML, platform, logger);
if (Config.UseHostedConfig) {
string val = storage.GetString (CACHED_CONFIG_PATH, string.Empty);
if (string.IsNullOrEmpty (val)) {
logger.Log ("No cached config available. Using bundled");
} else {
logger.Log ("Cached config found, attempting to parse");
try {
Config = new UnibillConfiguration(val, platform, logger);
if (Config.inventory.Count == 0) {
logger.LogError ("No purchasable items in cached config, ignoring.");
Config = new UnibillConfiguration (XML, platform, logger);
} else {
logger.Log (string.Format ("Using cached config with {0} purchasable items", Config.inventory.Count));
XML = val;
}
} catch (Exception e) {
logger.LogError ("Error parsing inventory: {0}", e.Message);
Config = new UnibillConfiguration(XML, platform, logger);
}
}
refreshCachedConfig (Config.HostedConfigUrl, logger);
} else {
logger.Log ("Not using cached inventory, using bundled.");
Config = new UnibillConfiguration(XML, platform, logger);
}
}
示例6: Execute
/// <summary>
/// Executes a powershell script
/// </summary>
/// <param name="folder">Folder where to execute the script</param>
/// <param name="file">Script to execute</param>
/// <param name="configuration">Configuration used</param>
/// <param name="log">Logger to use</param>
/// <param name="parameters">Parameters for the script</param>
public static void Execute(string folder, string file, string configuration, ILogger log, Dictionary<string, string> parameters)
{
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
Runspace runspace = RunspaceFactory.CreateRunspace(new Host(), runspaceConfiguration);
runspace.Open();
runspace.SessionStateProxy.Path.SetLocation(folder);
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
scriptInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
Pipeline pipeline = runspace.CreatePipeline();
Command myCommand = new Command(Path.Combine(folder, file));
foreach (var param in parameters.Keys)
{
myCommand.Parameters.Add(new CommandParameter("-" + param, parameters[param]));
}
myCommand.Parameters.Add(new CommandParameter("-Verb", "RunAs"));
pipeline.Commands.Add(myCommand);
Collection<PSObject> results = new Collection<PSObject>();
try
{
results = pipeline.Invoke();
}
catch (RuntimeException e)
{
log.Log(String.Join("\r\n", results.Select(x => x.ToString())) + "\r\n" + e.Message.ToString(), true);
return;
}
log.Log(String.Join("\r\n", results.Select(x => x.ToString())), pipeline.Error.Count > 0);
}
示例7: TestGetLocalGridEntities
private static void TestGetLocalGridEntities(Character me, EVE.ISXEVE.EVE eve, ILogger logger)
{
//var entities = EntityRepository.GetLocalGridEntities(me, eve);
eve.RefreshStandings();
var entities = eve.QueryEntities().Where(x => x.IsPC);
//var anObj = LavishScript.Objects.GetObject("Local", "Romvex");
//logger.Log(anObj.ToString());
var pilot = new Pilot("Romvex ");
logger.Log(pilot.ToString());
foreach (var entity in entities)
{
logger.Log(entity.Name);
logger.Log(LavishScriptObject.IsNullOrInvalid(entity.Owner.ToFleetMember).ToString());
logger.Log(entity.Owner.CharID.ToString());
logger.Log(entity.Owner.Corp.ID.ToString());
logger.Log(entity.AllianceID.ToString());
var standing = me.StandingTo(entity.CharID, entity.Corp.ID, entity.AllianceID);
logger.Log(standing.AllianceToAlliance.ToString());
logger.Log(standing.AllianceToCorp.ToString());
logger.Log(standing.AllianceToPilot.ToString());
logger.Log(standing.CorpToAlliance.ToString());
logger.Log(standing.CorpToCorp.ToString());
logger.Log(standing.CorpToPilot.ToString());
logger.Log(standing.MeToAlliance.ToString());
logger.Log(standing.MeToCorp.ToString());
logger.Log(standing.MeToPilot.ToString());
}
}
示例8: Build
public Task Build(string outputPath, ILogger logger)
{
var tcs = new TaskCompletionSource<object>();
try {
logger.Log("Building solution {0}.", Path.GetFileName(SolutionPath));
string propertyString = GetPropertyString();
if (!String.IsNullOrEmpty(propertyString)) {
propertyString = " /p:" + propertyString;
}
// Build the solution first
string log = ExecuteMSBuild(@"""{0}"" /verbosity:m /nologo{1}", SolutionPath, propertyString);
logger.Log(log);
}
catch (Exception ex) {
logger.Log("Building solution failed.", LogEntryType.Error);
logger.Log(ex);
tcs.TrySetException(ex);
return tcs.Task;
}
return BuildProject(outputPath, logger);
}
示例9: ExecuteDataPlan
public int ExecuteDataPlan(nDumpOptions nDumpOptions, ILogger logger, DataPlan dataPlan)
{
if (nDumpOptions.Export)
{
var queryExecutor = new QueryExecutor(nDumpOptions.SourceConnectionString);
ISelectionFilteringStrategy filteringStrategy = nDumpOptions.ApplyFilters ? (ISelectionFilteringStrategy)
new UseFilterIfPresentStrategy(queryExecutor, logger)
: new IgnoreFilterStrategy();
var exporter = new SqlDataExporter(logger, nDumpOptions.CsvDirectory,
queryExecutor, filteringStrategy);
try
{
exporter.ExportToCsv(dataPlan.SetupScripts, dataPlan.DataSelects);
}
catch (nDumpApplicationException ex)
{
logger.Log("Export To Csv Failed.\n" + ex.StackTrace);
return -1;
}
}
if (nDumpOptions.Transform)
{
var transformer = new DataTransformer(nDumpOptions.SqlDirectory, nDumpOptions.CsvDirectory,
logger);
try
{
transformer.ConvertCsvToSql(dataPlan.DataSelects);
}
catch (nDumpApplicationException ex)
{
logger.Log("Export To Csv Failed.\n" + ex.StackTrace);
return -1;
}
}
if (nDumpOptions.Import)
{
var importer = new SqlDataImporter(logger,
new QueryExecutor(nDumpOptions.TargetConnectionString), new IncrementingNumberSqlScriptFileStrategy(nDumpOptions.SqlDirectory));
try
{
importer.RemoveDataAndImportFromSqlFiles(dataPlan.DataSelects);
}
catch (nDumpApplicationException ex)
{
logger.Log("Import Of Sql Failed.\n" + ex.Message + "\n" + ex.StackTrace);
return -1;
}
}
return 0;
}
示例10: LoadCustomizations
public static INodeViewCustomizations LoadCustomizations(Assembly assem, ILogger logger)
{
if (cache.ContainsKey(assem)) return cache[assem];
var types = new Dictionary<Type, IEnumerable<Type>>();
try
{
var customizerType = typeof (INodeViewCustomization<>);
var customizerImps = assem.GetTypes().Where(t => !t.IsAbstract && ImplementsGeneric(customizerType, t));
foreach (var customizerImp in customizerImps)
{
var nodeModelType = GetCustomizerTypeParameters(customizerImp);
if (nodeModelType == null) continue;
if (types.ContainsKey(nodeModelType))
{
types[nodeModelType] = types[nodeModelType].Concat(new[] {customizerImp});
}
else
{
types.Add(nodeModelType, new[] {customizerImp});
}
}
}
catch (Exception ex)
{
logger.Log(string.Format(Resources.NodeViewCustomizationFindErrorMessage, assem.FullName));
logger.Log(ex.Message);
}
return new NodeViewCustomizations(types);
}
示例11: ConvertConsumptionToCsv
/// Takes a consumptionTempResults file and converts to csv file
/// Each info contains the <ScenarioName, Metric Key, Metric value>
public static bool ConvertConsumptionToCsv(string source, string destination, string requiredMetricKey, ILogger logger)
{
logger.Log("Entering ConvertConsumptionToCsv");
if (!File.Exists(source))
{
logger.Log($"File {source} does not exist");
return false;
}
try
{
var result = new List<string>();
string currentScenarioName = null;
using (XmlReader xmlReader = XmlReader.Create(source))
{
while (xmlReader.Read())
{
if ((xmlReader.NodeType == XmlNodeType.Element))
{
if (xmlReader.Name.Equals("ScenarioResult"))
{
currentScenarioName = xmlReader.GetAttribute("Name");
// These are not test results
if (string.Equals(currentScenarioName, "..TestDiagnostics.."))
{
currentScenarioName = null;
}
}
else if (currentScenarioName != null && xmlReader.Name.Equals("CounterResult"))
{
var metricKey = xmlReader.GetAttribute("Name");
if (string.Equals(metricKey, requiredMetricKey))
{
var metricScale = xmlReader.GetAttribute("Units");
xmlReader.Read();
var metricvalue = xmlReader.Value;
result.Add($"{currentScenarioName}, {metricKey} ({metricScale}), {metricvalue}");
}
}
}
}
}
File.WriteAllLines(destination, result);
}
catch (System.Exception e)
{
System.Console.WriteLine(e.Message);
System.Console.WriteLine(e.StackTrace);
return false;
}
return true;
}
示例12: ConnectAsync
/// <summary>
/// Largely synchronous, unfortunately
/// </summary>
public async Task ConnectAsync(ILogger logger)
{
logger = logger ?? new StubLogger();
await this.connectLock.WaitAsync();
{
logger.Log("Establishing connection with {0}@{1}", this.User, this.Host);
if (this.client == null)
this.client = new SshClient(this.Host, this.User, new PrivateKeyFile(new MemoryStream(Encoding.ASCII.GetBytes(this.Key))));
Exception lastException = null;
for (int i = 0; i < Retries && !this.client.IsConnected; i++)
{
try
{
await Task.Run(() => this.client.Connect());
}
catch (SshAuthenticationException e)
{
var msg = "SSH Authentication error:\n" + e.Format() + "\nMake sure you entered the right SSH user";
logger.Log(msg);
throw new Exception(msg, e);
}
catch (System.Net.Sockets.SocketException e)
{
lastException = e;
}
catch (SshException e)
{
lastException = e;
}
if (!this.client.IsConnected)
logger.Log("Connection attempt failed. Retrying...");
await Task.Delay(5000);
}
if (this.client.IsConnected)
{
this.IsConnected = true;
logger.Log("Connected");
}
else
{
var msg = "SSH connection failure: " + lastException.Message;
logger.Log(msg);
throw new Exception(msg, lastException);
}
}
this.connectLock.Release();
}
示例13: GetResponseStreamWrapped
public static Stream GetResponseStreamWrapped(this WebResponse resp, ILogger logger)
{
Stream nextStream = resp.GetResponseStream();
using (var rdr = new StreamReader(nextStream))
{
var respConent = rdr.ReadToEnd();
if (logger != null ) logger.Log("Response: ");
if (logger != null) logger.Log(respConent);
return new MemoryStream(Encoding.Default.GetBytes(respConent));
}
}
示例14: Log
public void Log(string message)
{
logger = LoggerService.getLoggerService();
logger.OpenLog();
logger.Log(message);
logger.CloseLog();
}
示例15: PlaygroundPresenter
public PlaygroundPresenter(IPlaygroundView view)
{
_view = view;
try
{
//// try some manual detection
// ...does not work in Sharepoint integrated mode!!!
//var cpa = (IContainerProviderAccessor) HttpContext.Current.ApplicationInstance;
//IContainerProvider cp = cpa.ContainerProvider;
//_logger = cp.RequestLifetime.Resolve<ILogger>();
// an easier way is:
this._logger = SPServiceLocator.GetRequestLifetime().Resolve<ILogger>();
if (!_view.IsPostback)
{
_logger.Log(typeof (PlaygroundPresenter), "Let's play (now with autofac loaded singleton)");
_view.SuccessMessage = "Let's play!!";
}
}
catch (Exception ex)
{
_view.ErrorMessage = "Playground is under construction: " + ex.Message;
}
}