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


C# Logger.Write方法代码示例

本文整理汇总了C#中Logger.Write方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Write方法的具体用法?C# Logger.Write怎么用?C# Logger.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Logger的用法示例。


在下文中一共展示了Logger.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadTasks

        static void LoadTasks(Logger logger, XmlDocument taskFile)
        {
            Tasks = new List<Task>();

            foreach (XmlNode node in taskFile.DocumentElement.ChildNodes)
            {
                if (Plugins.ContainsKey(node.Attributes["type"].Value))
                {
                    Type pluginType = Plugins[node.Attributes["type"].Value];
                    object[] args = new object[] { logger, node };
                    try
                    {
                        Task task = (Task)Activator.CreateInstance(pluginType, args);
                        Tasks.Add(task);
                    }
                    catch (Exception)
                    {
                        if (node.Attributes["name"] == null)
                            logger.Write(String.Format("Error creating unnamed task of type {0} (try checking the attributes in your taskfile!)", pluginType.Name), Priority.Error);
                        else
                            logger.Write(String.Format("Error creating '{1}' of type {0} (try checking the attributes in your taskfile!)", pluginType.Name, node.Attributes["name"].Value), Priority.Error);
                    }
                }
                else
                    logger.Write("Unable to find '" + node.Attributes["type"].Value + "' plugin", Priority.Error);
            }
        }
开发者ID:colourblind,项目名称:OhTehNoes,代码行数:27,代码来源:Program.cs

示例2: Initialize

        public void Initialize(Logger log, string password)
        {
            // get log instance to disk
            _log = log;

            // if stream are empty, create header page and save to stream
            if (_stream.Length == 0)
            {
                _log.Write(Logger.DISK, "initialize new datafile");

                // create a new header page in bytes
                var header = new HeaderPage();

                if(password != null)
                {
                    _log.Write(Logger.DISK, "datafile encrypted");

                    header.Password = AesEncryption.HashSHA1(password);
                    header.Salt = AesEncryption.Salt();
                }

                // write bytes on page
                this.WritePage(0, header.WritePage());
            }
        }
开发者ID:apkd,项目名称:LiteDB,代码行数:25,代码来源:StreamDiskService.cs

示例3: Main

        static void Main(string[] args)
        {
            var logger = new Logger("Main");
            var JSON_FILENAME = "configuration.json";

            try
            {

                var config = new Json.Deserializer().parseFromFile<GoogleOAuth2Config>(JSON_FILENAME);
                logger.Write(0, config.ToString());

                var token = new GoogleService.Authenticator().getAuthenticationToken(config);

                logger.Write(0, token);

                 string metrics = "ga:totalEvents";
                string dimensions =
                "ga:date,ga:hostname,ga:pageTitle,ga:dimension1,ga:eventAction,ga:eventCategory,ga:eventLabel";

                GoogleService.Fetch.getQueryAnalyticsResult(token, metrics, dimensions);

            }
            catch (Exception exc)
            {
                logger.Write((MessageType)4, exc.Message);

            }
        }
开发者ID:Anupamsdesk,项目名称:GoogleAnalytics,代码行数:28,代码来源:Program.cs

示例4: TestSources

		public void TestSources()
		{
			var logger = new Logger("logs");
			AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetFullPath(@"..\App_Data\"));

			var parallelOptions = new ParallelOptions // if server, sandboxerRunner and test run in one machine
			{
				MaxDegreeOfParallelism = Environment.ProcessorCount
			};

			var res = Parallel.ForEach(GetSources(), parallelOptions, async source =>
			{
				var id = String.Format("{0:D10}", source.Id);
				var executionService = new CsSandboxExecutionService();
				SubmissionResult runResult = null;
				try
				{
					runResult = await executionService.Submit(source.Code, id);
				}
				catch (Exception ex)
				{
					logger.Write(source, ex);
				}
				if (runResult != null && !IsCorrectSolution(source, runResult))
					logger.Write(source, runResult);
			});

			while (!res.IsCompleted)
			{
				Thread.Sleep(60*1000);
			}
		}
开发者ID:hexandr,项目名称:uLearn,代码行数:32,代码来源:ExecutionServiceMigration_Test.cs

示例5: getAuthenticationToken

        public string getAuthenticationToken(GoogleOAuth2Config config)
        {
            var logger = new Logger("GoogleService.Authenticator");
            var registry = new Windows.Registry.Helper(config.ApiAccessKey);

            var expiryTime = registry.getExpireTime();
            if (String.IsNullOrEmpty(expiryTime) || expiryTime.Length < 4)
            {
                expiryTime = FALLBACK_EXPIRY_DATE;
            }
            var ExpireDateTime = Convert.ToDateTime(expiryTime);
            var ExpireTimeNow = DateTime.UtcNow;
            TimeSpan span = ExpireDateTime - ExpireTimeNow;
            double iExpireLeft = span.TotalSeconds;

            logger.Write(0, "Expire time left (sec): " + iExpireLeft);

            if (iExpireLeft < 60) {
                logger.Write(0, "Requesting authentication token from server...");
                var tokenObject = requestAuthenticationToken(config);

                if (tokenObject.access_token == null)
                    throw new NullReferenceException("access_token is null");

                registry.putValue(Helper.SubKey.TokenName, tokenObject.access_token);
                registry.putInterval(Helper.SubKey.ExpireTime, tokenObject.expires_in);
                logger.Write(0, "Token Received successfully");
            }

            string accessToken = registry.getAccessToken();
            return accessToken;
        }
开发者ID:Anupamsdesk,项目名称:GoogleAnalytics,代码行数:32,代码来源:Authenticator.cs

示例6: ChatServer

        public ChatServer(string identifier, Config config)
        {
            Identifier = identifier;
            Context = new ChatServerContext(config);
            Endpoints = new Dictionary<string, ServerProtocol>();
            Log = new Logger($"Chat Server ({Identifier})");
            Log.Write(LogSeverity.Info, "Created chat server container.");

            string[] channels = Context.Config.Get("Chat.Context", "Channels", "Lounge").Split(' ');

            for (int i = 0; i < channels.Length; i++) {
                string configSection = $"Chat.Channel.{channels[i]}";

                Channel channel = new Channel {
                    Id = i + 1,
                    Name = "#" + (Context.Config.ContainsKey(configSection, "Name") ? Context.Config.Get<string>(configSection, "Name") : channels[i]).ToLower(),
                    Topic = Context.Config.ContainsKey(configSection, "Topic") ? Context.Config.Get<string>(configSection, "Topic") : "This channel has no topic.",
                    Created = DateTime.UtcNow
                };

                if (Context.Config.ContainsKey(configSection, "Password")) {
                    channel.SetPassword(Context.Config.Get<string>(configSection, "Password"));
                }

                if (Context.Config.ContainsKey(configSection, "MinimumHierarchy")) {
                    channel.MinimumHierarchy = Context.Config.Get<int>(configSection, "MinimumHierarchy");
                }

                Context.Channels.Add(channel);
                Log.Write(LogSeverity.Info, $"Created {channel.Name}.");
            }
        }
开发者ID:flashwave,项目名称:railgun,代码行数:32,代码来源:ChatServer.cs

示例7: LoadPlugins

        static void LoadPlugins(Logger logger)
        {
            Plugins = new Dictionary<string, Type>();

            DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "plugins"));
            foreach (FileInfo file in pluginDirectory.GetFiles("*.dll"))
            {
                logger.Write(String.Format("Searching {0} for plugins", file.Name), Priority.Debug);
                Assembly assembly = Assembly.LoadFile(file.FullName);
                foreach (Type type in assembly.GetTypes())
                {
                    object[] attributes = type.GetCustomAttributes(typeof(TaskAttribute), true);
                    if (type.IsSubclassOf(typeof(Task)) && attributes != null)
                    {
                        foreach (object attribute in attributes)
                        {
                            if (attribute is TaskAttribute)
                            {
                                logger.Write(String.Format("Loading plugin {0}", type.FullName), Priority.Debug);
                                TaskAttribute taskAttribute = (TaskAttribute)attributes[0];
                                Plugins[taskAttribute.TypeName] = type;
                            }
                        }
                    }
                }
            }
        }
开发者ID:colourblind,项目名称:OhTehNoes,代码行数:27,代码来源:Program.cs

示例8: SurfaceWindow1

        /// <summary>
        /// Default constructor.
        /// </summary>
        public SurfaceWindow1()
        {
            log = new Logger("Rememo");
            log.Write("Starting application");
            
            if (DiaryManager.ConfigExists())
            {
                InitializeComponent();

                clock.Elapsed += new System.Timers.ElapsedEventHandler(clock_Elapsed);
                log.Write("Config found!");
                clock.Enabled = true;
                log.Write("Clock enabled");
                log.Write("Welcome Text set");
            }
            else
            {  
                
                InitializeComponent();

                clock.Elapsed += new System.Timers.ElapsedEventHandler(clock_Elapsed);
                log.Write("No config file!");
                clock.Enabled = true;
                log.Write("clock enabled");
                welcomeText(false);
                
                
            }
            // Add handlers for Application activation events
            AddActivationHandlers();

        }
开发者ID:pjmoore92,项目名称:rememo,代码行数:35,代码来源:SurfaceWindow1.xaml.cs

示例9: Should_support_using_for_Indent

 public void Should_support_using_for_Indent()
 {
     var output = new StringWriter();
     var logger = new Logger(output);
     logger.Write("1");
     using(logger.Indent())
         logger.Write("2");
     logger.Write("3");
     Assert.AreEqual(string.Format("1{0}\t2{0}3{0}", output.NewLine), output.ToString());
 }
开发者ID:danaxa,项目名称:Pencil,代码行数:10,代码来源:LoggerTests.cs

示例10: Main

        static void Main(string[] args)
        {
            ILogger log = new Logger();
            log.Write("Hello World.");

            Console.ReadKey();
        }
开发者ID:0iron0,项目名称:Simon.Provider.Demo,代码行数:7,代码来源:Program.cs

示例11: Write_should_support_formatting

 public void Write_should_support_formatting()
 {
     var output = new StringWriter();
     var logger = new Logger(output);
     logger.Write("{0}+{1}", 1, 2);
     Assert.AreEqual("1+2" + output.NewLine, output.ToString());
 }
开发者ID:danaxa,项目名称:Pencil,代码行数:7,代码来源:LoggerTests.cs

示例12: OnUnhandledException

    private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
      var error = e.ExceptionObject as Exception;
      if (error == null)
        return;

      var logger = new Logger(AppDomain.CurrentDomain.BaseDirectory + "/UnhandledError.log");
      logger.Write(error);
    }
开发者ID:viktortat,项目名称:TCPChat,代码行数:9,代码来源:App.xaml.cs

示例13: Test_WriteLine_Calls_Write_With_Setup_Method

        public void Test_WriteLine_Calls_Write_With_Setup_Method()
        {
            // Arrange
            var stub = new StubILogWriter();
            var mock = stub.AsMock();
            mock.Setup(lw => lw.Write(It.IsAny<string>()));
            mock.Setup(lw => lw.Write(It.IsAny<int>()));

            var logger = new Logger(mock.Object);

            // Act
            logger.Write("Hello, logger!");
            logger.Write(42);

            // Assert
            // We're not explicitly stated what we're expecting.
            // mock.Setup expectations would be use.
            mock.Verify();
        }
开发者ID:SergeyTeplyakov,项目名称:VerificationFakes,代码行数:19,代码来源:MockSamples.cs

示例14: Prepare

        /// <summary>
        /// Environment startup.
        /// </summary>
        /// <param name="dataPath">Path used for data storage, leave null to just throw it in the same directory as the executables.</param>
        public static void Prepare(string dataPath = null)
        {
            Root = dataPath != null ? dataPath : AppDomain.CurrentDomain.BaseDirectory;

            if (!Directory.Exists(Root)) {
                DirectoryInfo dirInfo = Directory.CreateDirectory(dataPath);
                dirInfo.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
            }

            Log = new Logger("Railgun");
            Log.Write(LogSeverity.Info, "Environment prepared.");
            Config = new Config("Railgun");
        }
开发者ID:flashwave,项目名称:railgun,代码行数:17,代码来源:Env.cs

示例15: Server

        public Server(string identifier, ChatServerContext context)
            : base(identifier, context)
        {
            if (Hostname == null) {
                Hostname = Context.Config.Get("Chat.Protocols.IRC", "Hostname", "irc.flash.moe");
            }

            Log = new Logger($"IRC Server ({Identifier})");

            short bindPort = Context.Config.Get<short>("Chat.Protocols.IRC", "Port", 6667);
            Listener = new TcpListener(IPAddress.Any, bindPort);
            Log.Write(LogSeverity.Info, "Creating IRC server on port {0}.", bindPort.ToString());
        }
开发者ID:flashwave,项目名称:railgun,代码行数:13,代码来源:Server.cs


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