本文整理汇总了C#中System.Logger.Write方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Write方法的具体用法?C# Logger.Write怎么用?C# Logger.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Logger
的用法示例。
在下文中一共展示了Logger.Write方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeLoggers
public static void InitializeLoggers()
{
StatusLogger = new Logger("Status", Basic.ConsoleLocker, ConsoleColor.Green);
InfosLogger = new Logger("Infos", Basic.ConsoleLocker, ConsoleColor.Magenta, Config.GetBoolElement("DEBUG"));
ErrorsLogger = new Logger("Errors", Basic.ConsoleLocker, ConsoleColor.Yellow);
StatusLogger.Write(string.Format("Loggers loaded and started : MODE DEBUG = {0}", Config.GetBoolElement("DEBUG").ToString().ToUpper()));
}
示例2: Test_Clear
public void Test_Clear()
{
var node = new Node ("Node");
var log = new Logger ();
log.Write (node, 1, "Hello World");
Assert.AreEqual (1, log.LogCount);
log.Clear ();
Assert.AreEqual (0, log.LogCount);
}
示例3: Test_Write
public void Test_Write()
{
var node = new Node ("Node");
var log = new Logger ();
log.Write (node, 1, "Hello World");
Assert.AreEqual (1, log.LogCount);
Assert.AreEqual (1, log.Logs.Count ());
Assert.AreEqual ("Node", log.Logs.ElementAt (0).Node);
Assert.AreEqual (1, log.Logs.ElementAt (0).Priority);
Assert.AreEqual ("Hello World", log.Logs.ElementAt (0).Message);
}
示例4: Flush_test
public void Flush_test()
{
var mt = new MobileParamTest();
var headerMock = new Mock<IRequestRepository>();
headerMock.Setup<NameValueCollection>(s => s.QueryString).Returns(mt.PrepareHeaderRepository());
var sqlLoaderLogger = new Logger();
var mobileParam = new MobileParam(headerMock.Object);
var log = EntityMapping.Auto<MobileParam, CommunicationLog>(mobileParam);
log.DomainNameId = 11;
log.Url = "211.151.64.236/asdfsd/asd/f/sad/f/sd/f/sa/df/s/df?dfdsfsd=中文";
log.RequestBody = "{\"pid\":100,\"version\":{\"reserved\":2,\"minor\":8,\"major\":1},\"imei\":\"356516040152451\",\"imsi\":\"460001511666063\"}";
log.ActionId = 10012;
log.ResultCode = 0;
log.ProvinceId = 26;
log.CityId = 10012;
log.IPAddress = "101.222.33.258,25.36.556.89";
sqlLoaderLogger.Write<CommunicationLog>(log);
sqlLoaderLogger.FlushAll();
}
示例5: InitialiseLoggers
public static void InitialiseLoggers()
{
StatusLogger = new Logger("Status", Basic.ConsoleLocker, ConsoleColor.Green);
{
if (Config.GetConfig.GetBoolElement("Status_inConsole") == true)
StatusLogger.StartConsoleLogger();
if (Config.GetConfig.GetBoolElement("Status_inFile") == true)
StatusLogger.StartFileLogger();
}
InfosLogger = new Logger("Infos", Basic.ConsoleLocker, ConsoleColor.Magenta);
{
if (Config.GetConfig.GetBoolElement("Infos_inFile") == true)
InfosLogger.StartFileLogger();
if (Config.GetConfig.GetBoolElement("Infos_inConsole") == true)
InfosLogger.StartConsoleLogger();
}
ErrorsLogger = new Logger("Errors", Basic.ConsoleLocker, ConsoleColor.Yellow);
{
if (Config.GetConfig.GetBoolElement("Errors_inFile") == true)
ErrorsLogger.StartFileLogger();
if (Config.GetConfig.GetBoolElement("Errors_inConsole") == true)
ErrorsLogger.StartConsoleLogger();
}
CommandsLogger = new Logger("Commands", Basic.ConsoleLocker, ConsoleColor.Cyan);
{
if (Config.GetConfig.GetBoolElement("Commands_inFile") == true)
CommandsLogger.StartFileLogger();
if (Config.GetConfig.GetBoolElement("Commands_inConsole") == true)
CommandsLogger.StartConsoleLogger();
}
StatusLogger.Write("@[email protected] loaded and started !");
}
示例6: TestSelf
// ---------------------------------------------------------------------
#region TestSelf
// ---------------------------------------------------------------------
/// <summary>
/// Simple self test. See StreamTokenizerTestCase for full
/// tests.
/// </summary>
/// <returns>bool - true for success, false for failure.</returns>
public static bool TestSelf()
{
Logger log = new Logger("testSelf");
log.Verbosity = VerbosityLevel.Debug;
log.Info("Starting...");
string testString;
ArrayList tokens;
// setup tokenizer
StreamTokenizer tokenizer = new StreamTokenizer();
tokenizer.Settings.SetupForCodeParse();
tokenizer.Verbosity = VerbosityLevel.Debug;
//
// try string parse
//
log.Write("--------------------------------------------------------\n");
log.Info("string parse:");
log.Write("--------------------------------------------------------\n");
tokens = new ArrayList();
testString = "-1.2ej";
tokenizer.Settings.DoUntermCheck = false;
tokenizer.Settings.GrabWhitespace = false;
if (!tokenizer.TokenizeString(testString, tokens))
{
log.Error("Unable to parse into token vector.");
return (false);
}
foreach (Token t in tokens) log.Info("Token = '{0}'", t);
tokens = new ArrayList();
//
// try NextToken style
//
// log.Write("--------------------------------------------------------\n");
// log.Info("NextToken use");
// log.Write("--------------------------------------------------------\n");
//string fileName = "st-testSelf.tmp";
//testString = "this is a simple string";
//tokenizer.TextReader = new StringReader(testString);
//tokenizer.TextReader = File.OpenText(fileName);
//Token token;
//while (tokenizer.NextToken(out token)) log.Info("Token = '{0}'", token);
//
// try TokenizeFile
//
log.Write("--------------------------------------------------------\n");
log.Info("Tokenize missing file");
log.Write("--------------------------------------------------------\n");
string nonExistentFileName = "ThisFile better not exist";
bool caughtIt = false;
try
{
tokenizer.TokenizeFile(nonExistentFileName);
}
catch (FileNotFoundException e)
{
log.Info("Correctly caught exception: {0}: {1}", e.GetType(), e.Message);
caughtIt = true;
}
if (!caughtIt)
{
log.Error("Didn't get a file not found exception from TokenizeFile.");
return (false);
}
//
// test line numbers in tokens
//
// done
log.Info("Done.");
return (true);
}
示例7: realtime_log_model
public void realtime_log_model()
{
var sqlLoaderLogger = new Logger();
var log = new ChannelInfo();
log.Key = "中文";
log.DisplayName = "460001511666063";
DateTime start = DateTime.Now;
for (int i = 0; i < 100; i++)
{
//Random r = new Random();
sqlLoaderLogger.Write<ChannelInfo>(log);
//Thread.Sleep( 2000);
}
DateTime end = DateTime.Now;
Console.WriteLine((end - start).TotalMilliseconds);
}
示例8: pool_log_model
//[Fact]
public void pool_log_model()
{
var mt = new MobileParamTest();
var headerMock = new Mock<IRequestRepository>();
headerMock.Setup<NameValueCollection>(s => s.QueryString).Returns(mt.PrepareHeaderRepository());
var sqlLoaderLogger = new Logger();
var mobileParam = new MobileParam(headerMock.Object);
var log = EntityMapping.Auto<MobileParam, CommunicationLog>(mobileParam);
log.DomainNameId = 11;
log.Url = "211.151.64.236/asdfsd/asd/f/sad/f/sd/f/sa/df/s/df?dfdsfsd=中文";
log.RequestBody = "{\"pid\":100,\"version\":{\"reserved\":2,\"minor\":8,\"major\":1},\"imei\":\"356516040152451\",\"imsi\":\"460001511666063\"}";
log.ActionId = 10012;
log.ResultCode = 0;
log.ProvinceId = 26;
log.CityId = 10012;
log.IPAddress = "101.222.33.258,25.36.556.89";
DateTime start = DateTime.Now;
for (int i = 0; i < 10000; i++)
{
//Random r = new Random();
sqlLoaderLogger.Write<CommunicationLog>(log);
//Thread.Sleep( 2000);
}
DateTime end = DateTime.Now;
Console.WriteLine((end-start).TotalMilliseconds);
}
示例9: TestSelf
/// <summary>
/// Simple test of some ParseUtil methods.
/// </summary>
/// <returns>bool - true for all passed, false otherwise</returns>
public static bool TestSelf()
{
Logger log = new Logger("ParseUtil: TestSelf");
log.Info("Starting...");
StreamTokenizer tokenizer = new StreamTokenizer();
tokenizer.Verbosity = VerbosityLevel.Warn;
// FindMatch
ArrayList alist = new ArrayList();
tokenizer.TokenizeString("{ [ ] '}' }", alist);
foreach(Token t in alist) log.Debug("Token = {0}", t);
Token[] tarray = (Token[])alist.ToArray(typeof(Token));
int i = 0;
if (!FindMatch(tarray, ref i, '{'))
{
log.Error("FindMatch failed to match { char");
return(false);
}
if (i != 4)
{
log.Error("FindMatch got the wrong answer {0}", i);
return(false);
}
else log.Info("FindMatch worked.");
//
// try BuildArray
//
ArrayList tokens = new ArrayList();
tokenizer.TokenizeString("1 2 3 4 5", tokens);
foreach(Token t in tokens) log.Debug("Token = {0}", t);
i = 0;
Int16[] shorts = (short[])ParseUtil.BuildArray(tokens, ref i, typeof(Int16), null,
-1, log);
if (shorts == null)
{
log.Error("Unable to BuildArray of shorts.");
return(false);
}
log.Info("Parsed shorts:");
foreach(Int16 s in shorts)
{
log.Write("{0}, ", s);
}
log.WriteLine("");
//
// try BuildArray of floats, char terminated
//
tokens.Clear();
tokenizer.TokenizeString("1 2 ; 3 4", tokens);
foreach(Token t in tokens) log.Debug("Token = {0}", t);
i = 0;
Single[] floats = (float[])ParseUtil.BuildArray(tokens, ref i, typeof(Single),
new CharToken(';'), -1, log);
if (floats == null)
{
log.Error("Unable to BuildArray of floats.");
return(false);
}
log.Info("Parsed floats:");
foreach(float f in floats)
{
log.Write("{0}, ", f);
}
log.WriteLine("");
if (i != 2)
{
log.Error("BuildArray left i = {0} which is incorrect");
return(false);
}
//
// try BuildArray on high-precision floats
//
tokens.Clear();
float f1 = 1.23456f;
float f2 = 2.34567f;
tokenizer.TokenizeString(String.Format("{0:f6} {1:f6}", f1,f2), tokens);
foreach(Token t in tokens) log.Debug("Token = {0}", t);
i = 0;
floats = (float[])ParseUtil.BuildArray(tokens, ref i, typeof(Single),
null, -1, log);
if (floats == null)
//.........这里部分代码省略.........
示例10: WriteWithSucceeds
public void WriteWithSucceeds()
{
// Arrange
var message = "{0}{1}";
var arg0 = "42";
var arg1 = "arbitrary-string";
// Act
var sut = new Logger();
sut.Write(message, arg0, arg1);
// Assert
// N/A
}
示例11: WriteWithEmptyStringThrowsContractException
public void WriteWithEmptyStringThrowsContractException()
{
// Arrange
var message = string.Empty;
var arg0 = default(object);
var arg1 = default(object);
// Act
var sut = new Logger();
sut.Write(message, arg0, arg1);
// Assert
// N/A
}
示例12: PrintVector
private void PrintVector(Logger.ILogger logger, double[] vector)
{
for (int i = 0; i < vector.Length; ++i)
{
logger.Write(vector[i].ToString() + "; ");
}
logger.WriteLn("");
}
示例13: PrintMatrix
private void PrintMatrix(Logger.ILogger logger, double[][] matrix)
{
for (int i = 0; i < matrix.Length; ++i)
{
for (int j = 0; j < matrix[i].Length; ++j)
{
logger.Write(matrix[i][j].ToString() + "; ");
}
logger.WriteLn("");
}
}