本文整理汇总了C#中Log.Info方法的典型用法代码示例。如果您正苦于以下问题:C# Log.Info方法的具体用法?C# Log.Info怎么用?C# Log.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log.Info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestContext
public void TestContext ()
{
var queue = new Loggers.Queue();
var log = new Log(this);
using (Log.RegisterInstance(
new Instance()
{
Properties = new[]
{
"StackFrame.File",
"StackFrame.Line",
"StackFrame.Type",
"StackFrame.Method"
},
Logger = queue,
Buffer = 0,
Synchronous = true
}
)
)
{
var frame = new System.Diagnostics.StackFrame(0, true);
log.Info("test");
var evt = queue.Dequeue().Single();
Assert.AreEqual(evt["StackFrame.File"], frame.GetFileName());
Assert.AreEqual(evt["StackFrame.Line"], frame.GetFileLineNumber() + 1);
Assert.AreEqual(evt["StackFrame.Type"], frame.GetMethod().DeclaringType.FullName);
Assert.AreEqual(evt["StackFrame.Method"], frame.GetMethod().Name);
}
}
示例2: Main
public static void Main(string[] args)
{
Configuration config = Configuration.LoadConfiguration("settings.json");
Log mainLog = new Log (config.MainLog, null);
//byte counter = 0;
foreach (Configuration.BotInfo info in config.Bots)
{
//Console.WriteLine("--Launching bot " + info.DisplayName +"--");
mainLog.Info ("Launching Bot " + info.DisplayName + "...");
new Thread(() =>
{
int crashes = 0;
while (crashes < 1000)
{
try
{
new Bot(info, config.ApiKey);
}
catch (Exception e)
{
mainLog.Error ("Error With Bot: "+e);
crashes++;
}
}
}).Start();
Thread.Sleep(5000);
}
}
示例3: LoadConfiguration
/// <summary>
/// Loads a configuration file to use when creating bots.
/// </summary>
/// <param name="configFile"><c>false</c> if there was problems loading the config file.</param>
public bool LoadConfiguration(string configFile)
{
if (!File.Exists(configFile))
return false;
try
{
ConfigObject = Configuration.LoadConfiguration(configFile);
}
catch (JsonReaderException)
{
// handle basic json formatting screwups
ConfigObject = null;
}
if (ConfigObject == null)
return false;
useSeparateProcesses = ConfigObject.UseSeparateProcesses;
mainLog = new Log(ConfigObject.MainLog, null, Log.LogLevel.Debug);
for (int i = 0; i < ConfigObject.Bots.Length; i++)
{
Configuration.BotInfo info = ConfigObject.Bots[i];
mainLog.Info("Launching Bot " + info.DisplayName + "...");
var v = new RunningBot(useSeparateProcesses, i, ConfigObject);
botProcs.Add(v);
}
return true;
}
示例4: TestContext
public void TestContext()
{
var queue = new Loggers.Queue();
var log = new Log(this);
using (Log.RegisterInstance(
new Instance()
{
Properties = new[]
{
"Environment.MachineName",
"Environment.UserName",
"Environment.UserDomainName",
"Environment.CurrentDirectory",
"Environment.OSVersion",
"Environment.ProcessorCount",
"Environment.SystemRoot"
},
Logger = queue,
Buffer = 0,
Synchronous = true
}
)
)
{
log.Info("test");
var evt = queue.Dequeue().Single();
Assert.AreEqual(evt["Environment.MachineName"], Environment.MachineName);
Assert.AreEqual(evt["Environment.UserName"], Environment.UserName);
Assert.AreEqual(evt["Environment.UserDomainName"], Environment.UserDomainName);
Assert.AreEqual(evt["Environment.CurrentDirectory"], Environment.CurrentDirectory);
Assert.AreEqual(evt["Environment.OSVersion"], Convert.ToString(Environment.OSVersion));
Assert.AreEqual(evt["Environment.ProcessorCount"], Environment.ProcessorCount);
Assert.AreEqual(evt["Environment.SystemRoot"], Environment.GetEnvironmentVariable("SystemRoot"));
}
}
示例5: TestContext
public void TestContext()
{
var queue = new Loggers.Queue();
var log = new Log(this);
using (Log.RegisterInstance(
new Instance()
{
Properties = new[]
{
"Thread.ID",
"Thread.StackTrace"
},
Logger = queue,
Buffer = 0,
Synchronous = true
}
)
)
{
log.Info("test");
var evt = queue.Dequeue().Single();
Assert.AreEqual(evt["Thread.ID"], System.Threading.Thread.CurrentThread.ManagedThreadId);
Assert.IsTrue(((String)evt["Thread.StackTrace"]).Contains("TestContext"));
}
}
示例6: Main
static void Main(string[] args)
{
// with the default implementations
ILogAdapter logAdapter = new TraceLogAdapter(null);
ILog log = new Log(logAdapter);
log.Info("Info message", 1);
log.Warning("Warning message", 1);
log.Critical("Critical message", 2);
// Example with a custom implementation
Console.WriteLine("");
Console.WriteLine("Example with a custom implementation");
MyLogSettings settings = new MyLogSettings();
logAdapter = new MyLogAdapter(settings);
log = new Log(logAdapter);
log.Info("Info message", 1);
log.Warning("Warning message", 1);
log.Critical("Critical message", 2);
Console.WriteLine("Terminé");
Console.ReadLine();
}
示例7: Main
static void Main(string[] args)
{
log4net.Config.XmlConfigurator.Configure();
var log = new Log();
log.Info("Startup");
var servers = new List<ServerInfo>();
using (var dc = new Arma3BeClientContext())
{
servers = dc.ServerInfo.Where(x => x.Active).ToList();
}
var models = servers.Select(x=>OpenServerInfo(x, log)).ToList();
while (true)
{
try
{
var t = Task.Run(() => run(models));
t.Wait();
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
示例8: AddEntry_CreateEntryWithInvalidStrings_ArgumentNullException
public void AddEntry_CreateEntryWithInvalidStrings_ArgumentNullException(string input)
{
Console.WriteLine(input.Length);
var uut = new Log(new ConsoleOutput(), new FileFormatter());
var ex = Assert.Throws<Log.LogEntry.StringLengthValidationException>(() => uut.Info(input));
Assert.That(ex.Message, Is.EqualTo("LogEntry must be between " +
Log.MINCHARLENGTH + " and " +
Log.MAXCHARLENGTH + " characters in length."));
}
示例9: Main
static void Main(string[] args)
{
var log = new Log();
var statistics = new Statistics(log);
var programConfiguration = new ProgramConfiguration();
if (!programConfiguration.Initialize(args))
return;
log.IsVerbose = programConfiguration.IsVerbose;
INetworkNode networkNode;
switch (programConfiguration.Direction)
{
case DirectionTypes.Sender:
{
networkNode = new Sender(log, statistics, programConfiguration);
log.Info("Application initialized - press Escape to exit.");
}
break;
case DirectionTypes.Receiver:
{
networkNode = new Receiver(log, statistics, programConfiguration);
log.Info("Application initialized - press Escape to exit.");
}
break;
default:
throw new Exception("Invalid network node direction.");
}
networkNode.Start();
statistics.StartPrintStatistics(programConfiguration.Direction);
while (Console.ReadKey(true).Key != ConsoleKey.Escape)
{
}
log.Info("Application shutting down...");
}
示例10: AddEntry_CreateLogEntries_EntriesIncreased
public void AddEntry_CreateLogEntries_EntriesIncreased(int input)
{
var uut = new Log(new ConsoleOutput(), new FileFormatter());
int i = input;
while (i > 0)
{
uut.Info(testString);
i--;
}
Assert.That(uut.NumberOfEntries, Is.EqualTo(input));
}
示例11: Write_OutputEntryToConsole_EntryOutputted
public void Write_OutputEntryToConsole_EntryOutputted()
{
string infoString = "Dette er bare en smule info!";
var output = Substitute.For<ILogOutput>();
string result = null;
output.Write(Arg.Do<string>(arg => result = arg));
using ( var uut = new Log(output, new FileFormatter()))
{
uut.Info(infoString);
}
Assert.That(result.Contains(infoString));
}
示例12: WatersLockmassPerfTest
public void WatersLockmassPerfTest()
{
Log.AddMemoryAppender();
TestFilesZip = "https://skyline.gs.washington.edu/perftests/PerfTestLockmass.zip";
TestFilesPersistent = new[] { "ID19638_01_UCA195_2533_082715.raw" }; // List of files that we'd like to unzip alongside parent zipFile, and (re)use in place
MsDataFileImpl.PerfUtilFactory.IssueDummyPerfUtils = false; // Turn on performance measurement
RunFunctionalTest();
var logs = Log.GetMemoryAppendedLogEvents();
var stats = PerfUtilFactory.SummarizeLogs(logs, TestFilesPersistent); // Show summary
var log = new Log("Summary");
if (TestFilesDirs != null)
log.Info(stats.Replace(TestFilesDir.PersistentFilesDir, "")); // Remove tempfile info from log
}
示例13: WatersIMSImportTest
public void WatersIMSImportTest()
{
Log.AddMemoryAppender();
TestFilesZip = "https://skyline.gs.washington.edu/perftests/PerfImportResultsWatersIMS.zip";
TestFilesPersistent = new[] { "ID12692_01_UCA168_3727_040714.raw", "ID12692_01_UCA168_3727_040714_IA_final_fragment.csv" }; // List of files that we'd like to unzip alongside parent zipFile, and (re)use in place
MsDataFileImpl.PerfUtilFactory.IssueDummyPerfUtils = false; // Turn on performance measurement
RunFunctionalTest();
var logs = Log.GetMemoryAppendedLogEvents();
var stats = PerfUtilFactory.SummarizeLogs(logs, TestFilesPersistent); // Show summary
var log = new Log("Summary");
if (TestFilesDirs != null)
log.Info(stats.Replace(TestFilesDir.PersistentFilesDir, "")); // Remove tempfile info from log
}
示例14: AgilentIMSImportTest
public void AgilentIMSImportTest()
{
Log.AddMemoryAppender();
TestFilesZip = "https://skyline.gs.washington.edu/perftests/PerfImportResultsAgilentIMSv3.zip";
TestFilesPersistent = new[] { "19pep_1700V_pos_3May14_Legolas.d", "19pep_1700V_CE22_pos_5May14_Legolas.d" }; // list of files that we'd like to unzip alongside parent zipFile, and (re)use in place
MsDataFileImpl.PerfUtilFactory.IssueDummyPerfUtils = false; // turn on performance measurement
RunFunctionalTest();
var logs = Log.GetMemoryAppendedLogEvents();
var stats = PerfUtilFactory.SummarizeLogs(logs, TestFilesPersistent); // show summary
var log = new Log("Summary");
if (TestFilesDirs != null)
log.Info(stats.Replace(TestFilesDir.PersistentFilesDir, "")); // Remove tempfile info from log
}
示例15: TestContext
public void TestContext()
{
var queue = new Loggers.Queue();
var log = new Log(this);
using (Log.RegisterInstance(
new Instance()
{
Properties = new[]
{
"Process.ID",
"Process.Name",
"Process.StartTime",
"Process.PeakVirtualMemory",
"Process.PeakPagedMemory",
"Process.PeakWorkingSetMemory",
"Process.ProcessorTime",
"Process.PrivilegedProcessorTime",
"Process.UserProcessorTime"
},
Logger = queue,
Buffer = 0,
Synchronous = true
}
)
)
{
log.Info("test");
var evt = queue.Dequeue().Single();
using (var process = System.Diagnostics.Process.GetCurrentProcess())
{
Assert.AreEqual(evt["Process.ID"], process.Id);
Assert.AreEqual(evt["Process.Name"], process.ProcessName);
Assert.AreEqual(evt["Process.StartTime"], process.StartTime);
Assert.IsTrue((Int64)evt["Process.PeakVirtualMemory"] > 0);
Assert.IsTrue((Int64)evt["Process.PeakPagedMemory"] > 0);
Assert.IsTrue((Int64)evt["Process.PeakWorkingSetMemory"] > 0);
Assert.IsTrue((TimeSpan)evt["Process.ProcessorTime"] > TimeSpan.FromTicks(0));
Assert.IsTrue((TimeSpan)evt["Process.PrivilegedProcessorTime"] > TimeSpan.FromTicks(0));
Assert.IsTrue((TimeSpan)evt["Process.UserProcessorTime"] > TimeSpan.FromTicks(0));
}
}
}