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


C# Logger.Write方法代码示例

本文整理汇总了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()));
        }
开发者ID:T4NK,项目名称:SunDofus,代码行数:8,代码来源:Loggers.cs

示例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);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:11,代码来源:TestLogger.cs

示例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);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:12,代码来源:TestLogger.cs

示例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();
        }
开发者ID:itabas016,项目名称:AppStores,代码行数:21,代码来源:TYD_CommunicationLogTest.cs

示例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 !");
        }
开发者ID:T4NK,项目名称:SunDofus,代码行数:39,代码来源:Loggers.cs

示例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);
        }
开发者ID:intille,项目名称:mitessoftware,代码行数:85,代码来源:StreamTokenizer.cs

示例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);
        }
开发者ID:itabas016,项目名称:AppStores,代码行数:20,代码来源:TYD_CommunicationLogTest.cs

示例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);
        }
开发者ID:itabas016,项目名称:AppStores,代码行数:30,代码来源:TYD_CommunicationLogTest.cs

示例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) 
//.........这里部分代码省略.........
开发者ID:intille,项目名称:mitessoftware,代码行数:101,代码来源:ParseUtil.cs

示例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
        }
开发者ID:dfensgmbh,项目名称:biz.dfch.CS.Appclusive.Scheduler,代码行数:14,代码来源:ILoggerTest.cs

示例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
        }
开发者ID:dfensgmbh,项目名称:biz.dfch.CS.Appclusive.Scheduler,代码行数:14,代码来源:ILoggerTest.cs

示例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("");
 }
开发者ID:JimmHub,项目名称:odoStuff,代码行数:8,代码来源:Form1.cs

示例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("");
     }
 }
开发者ID:JimmHub,项目名称:odoStuff,代码行数:11,代码来源:Form1.cs


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