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


C# ILog.Write方法代码示例

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


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

示例1: Controller

        public Controller()
        {
            _mainForm = new MainForm(this);
            _settings = new SettingsRepository("SerialPortControl.xml");
            _theLogger = new Log();
            _trayIcon = new TrayIcon();

            _trayIcon.ShowSettings += new EventHandler(OnShowSettings);
            _trayIcon.Exit += new EventHandler(OnExitRequest);
            _trayIcon.ToggleListening += new EventHandler(OnToggleListening);
            ShowTrayIcon();

            if (_settings.SettingsFileExists)
            {
                _settings.Load();
                Commands = _settings.Commands;
                SerialPort = _settings.SerialPort;
                WriteLog = _settings.WriteLog;
                _theLogger.Enabled = WriteLog;
                _theLogger.Write("Settings loaded from XML file.");
            }
            else
            {
                ShowMainForm();
                _theLogger.Write("Settings XML file created.");
            }

            if (SerialPort.Configurations.PortNames.Count() == 0)
            {
                MessageBox.Show("Unable to find any available COM ports on your system. Serial Port Control is cannot function.", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            if (!_settings.SettingsFileExists)
            {
                MessageBox.Show("Unable to find any configuration on your system. Serial Port Control is cannot function.", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            _theWatcher = new SerialPortWatcher(SerialPort);
            _theWatcher.ReceivedData += new EventHandler<ReceivedDataEventArgs>(OnReceivedData);
            _theWatcher.StartedListening += new EventHandler(OnConnected);
            _theWatcher.StoppedListening += new EventHandler(OnDisconnected);

            if (_settings.Listening)
                _theWatcher.Start();
        }
开发者ID:daniel-white,项目名称:SerialPortControl,代码行数:47,代码来源:Controller.cs

示例2: CopyInto

 public void CopyInto(ILog other)
 {
     lock (entries)
     {
         foreach (string entry in entries)
             other.Write(entry);
     }
 }
开发者ID:julianhaslinger,项目名称:Amnesia,代码行数:8,代码来源:SerializableLog.cs

示例3: Validate

        public virtual bool Validate(ILog log)
        {
            bool result = true;
            if (Type.IsNullOrWhiteSpace())
            {
                log.Write("{0} type is empty.", GetType().Name);
                result = false;
            }

            if (Category.IsNullOrWhiteSpace())
            {
                log.Write("{0} category is empty.", GetType().Name);
                result = false;
            }

            return result;
        }
开发者ID:DieselPuppet,项目名称:DatingDash,代码行数:17,代码来源:CategorizedItem.cs

示例4: Start

 public int Start()
 {
     listener = new TcpListener(endPoint);
     listener.Start();
     log = logFactory.ForEndpoint(new Uri("listen://" + listener.LocalEndpoint));
     log.Write(EventType.ListenerStarted, "Listener started");
     Accept();
     return ((IPEndPoint)listener.LocalEndpoint).Port;
 }
开发者ID:ruslander,项目名称:Halibut,代码行数:9,代码来源:SecureListener.cs

示例5: Start

 public int Start()
 {
     listener = new TcpListener(endPoint);
     if (endPoint.Address.AddressFamily == AddressFamily.InterNetworkV6)
     {
         listener.Server.DualMode = true;
     }
     listener.Start();
     log = logFactory.ForEndpoint(new Uri("listen://" + listener.LocalEndpoint));
     log.Write(EventType.ListenerStarted, "Listener started");
     Accept();
     return ((IPEndPoint)listener.LocalEndpoint).Port;
 }
开发者ID:BradBarnich,项目名称:Halibut,代码行数:13,代码来源:SecureListener.cs

示例6: CheckRequiredFiles

        public static void CheckRequiredFiles(ILog log)
        {
            try
            {
                Assembly a = Assembly.Load("Core");
                AssemblyName an = a.GetName();
                log.Write("Core: {0}", an.Version.ToString());

                Assembly a3 = Assembly.Load("MediaPortal");
                AssemblyName an3 = a3.GetName();
                log.Write("MediaPortal: {0}", an3.Version.ToString());

                Assembly a2 = Assembly.Load("ICSharpCode.SharpZipLib");
                AssemblyName an2 = a2.GetName();
                log.Write("ICSharpCode.SharpZipLib: {0} (0.85.5.452 or better recommended)", an2.Version.ToString());

                string mediaInfoVersion = "DLL Not found";
                try
                {
                    if (File.Exists(Config.GetFolder(Config.Dir.Base) + @"\MediaInfo.dll"))
                    {
                        FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Config.GetFolder(Config.Dir.Base) + @"\MediaInfo.dll");
                        mediaInfoVersion = string.Format("{0}.{1}.{2}.{3}", fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart);
                    }
                    else if (File.Exists(Config.GetFolder(Config.Dir.Plugins) + @"\windows\MediaInfo.dll"))
                    {
                        FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Config.GetFolder(Config.Dir.Plugins) + @"\windows\MediaInfo.dll");
                        mediaInfoVersion = string.Format("{0}.{1}.{2}.{3}", fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart);
                    }

                }
                catch { }

                log.Write("MediaInfo: {0} (0.7.20.0 or better recommended)", mediaInfoVersion);

                log.Write("Base Folder: {0}", Config.GetFolder(Config.Dir.Base));
                log.Write("Skin Folder: {0}", Config.GetFolder(Config.Dir.Skin));
                log.Write("Plugins Folder: {0}", Config.GetFolder(Config.Dir.Plugins));
            }
            catch (Exception ex)
            {
                log.Write("CheckRequiredFiles: {0}", ex.ToString());
            }
        }
开发者ID:dizzydezz,项目名称:jmm,代码行数:44,代码来源:Utils.cs

示例7: Logging

        private static void Logging(ILog logger)
        {
            string message = string.Empty;
            var counter = 0;

            Console.WriteLine("the process start : {0} of: {1}", DateTime.Now.ToString(dateFormat), logger.GetType().ToString());

            System.Threading.Thread.Sleep(50);

            for (counter = 0; counter < MAX_COUNTER; counter++)
            {
                message = string.Format("The Flow number: {0} of {1}", counter, logger.GetType().ToString());
                logger.Write(message);
            }

            System.Threading.Thread.Sleep(50);

            Console.WriteLine("the process end : {0} of: {1}", DateTime.Now.ToString(dateFormat), logger.GetType().ToString());
        }
开发者ID:seymourpoler,项目名称:Utils,代码行数:19,代码来源:Program.cs

示例8: Start

        public int Start()
        {
            listener = new TcpListener(endPoint);
            if (endPoint.Address.AddressFamily == AddressFamily.InterNetworkV6)
            {
                listener.Server.DualMode = true;
            }
            listener.Start();

#if CAN_GET_SOCKET_HANDLE
            // set socket handle as not inherited so that when tentacle runs powershell
            // with System.Diagnostics.Process those scripts don't lock the socket
            SetHandleInformation(listener.Server.Handle, HANDLE_FLAGS.INHERIT, HANDLE_FLAGS.None);
#endif

            log = logFactory.ForEndpoint(new Uri("listen://" + listener.LocalEndpoint));
            log.Write(EventType.ListenerStarted, "Listener started");
            Task.Run(async () => await Accept()); 
            return ((IPEndPoint)listener.LocalEndpoint).Port;
        }
开发者ID:OctopusDeploy,项目名称:Halibut,代码行数:20,代码来源:SecureListener.cs

示例9: ProfileAction

        /// <summary>
        ///     Performs a quick profile of an action.
        ///     <remarks>This should be used for simple actions which could possibly be resource intensive.</remarks>
        /// </summary>
        /// <param name="description">Description of the action being profiled.</param>
        /// <param name="iterations">Total iterations to perform.</param>
        /// <param name="func">The action to profile.</param>
        /// <param name="log">The <see cref="ILog" /> instance for this class to use.</param>
        public static void ProfileAction(string description, int iterations, Action func, ILog log)
        {
            // Warm up 
            func();

            var watch = new Stopwatch();

            // Clean up
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            watch.Start();
            for (var i = 0; i < iterations; i++)
            {
                func();
            }
            watch.Stop();
            log.Write("Total time to complete: " +
                watch.Elapsed.TotalMilliseconds.ToString(CultureInfo.InvariantCulture));
        }
开发者ID:jasteph,项目名称:MemorySharp,代码行数:29,代码来源:BenchMarkHelper.cs

示例10: Load

        public static SpawnItem Load(XmlElement elem, ILog log)
        {
            string type = elem.Name;
            if (!Pack.SpawnItemConfig.Types.Keys.Contains(type))
                throw new CommonException("Unknown type: {0}", type);

            var result = new SpawnItem(type, elem.GetFloatAttribute(DelayAttribName));

            foreach (XmlElement attachElem in elem.GetChildElements())
            {
                try
                {
                    result.Attachments.Add(SpawnItemAttachment.Load(attachElem));
                }
                catch (Exception ex)
                {
                    log.Write("Error while loading attachment: {0}. Skipped.", ex.Message);
                }
            }

            return result;
        }
开发者ID:DieselPuppet,项目名称:DatingDash,代码行数:22,代码来源:SpawnItem.cs

示例11: LogResponse

        static void LogResponse(Handler.Response response, ILog log)
        {
            if (response.AsyncLog.Entries.Count() > 0)
            {
                log.Write("Log entries written before this Amnesia command:");
                foreach (string entry in response.AsyncLog.Entries)
                    log.Write(entry);
            }

            foreach (string entry in response.Log.Entries)
                log.Write(entry);
        }
开发者ID:vc3,项目名称:Amnesia,代码行数:12,代码来源:Session.cs

示例12: CloseConnections

        /// <summary>
        /// Closes all database connections associated with the session.
        /// </summary>
        internal static void CloseConnections(ILog log)
        {
            List<AmnesiaDbConnection> oldConnections = new List<AmnesiaDbConnection>();

            lock (connections)
            {
                foreach (AmnesiaDbConnection c in connections.Values)
                    oldConnections.Add(c);

                connections.Clear();
            }

            foreach (AmnesiaDbConnection connection in oldConnections)
            {
                try
                {
                    using (LockConnection(connection))
                    {
                        if (connection.Real.State == ConnectionState.Open)
                        {
                            log.Write("Closing: " + connection.Real.ConnectionString);
                            connection.Real.Close();
                        }
                        else
                        {
                            log.Write("Already closed: " + connection.Real.ConnectionString);
                        }
                    }
                }
                catch { }
            }
        }
开发者ID:vc3,项目名称:Amnesia,代码行数:35,代码来源:Session.cs

示例13: LogFoundAddressToFile

 /// <summary>
 ///     Logs the pattern scan result to a text file as a useable pattern format for C#.
 /// </summary>
 /// <param name="log">The <see cref="ILog" /> member to use to log the result.</param>
 /// <param name="name">Name that represents the address.ed.</param>
 /// <param name="address">The address found from the pattern scan.</param>
 public static void LogFoundAddressToFile(ILog log, string name, IntPtr address)
 {
     try
     {
         log.Write(FormatAddressForFileLog(name, address));
     }
     catch (Exception e)
     {
         log.Write(e.ToString());
     }
 }
开发者ID:jasteph,项目名称:MemorySharp,代码行数:17,代码来源:PatternCore.cs

示例14: Pause

        /// <summary>
        /// Stop all incoming activities and wait for the current activities to complete. When
        /// this method returns, all activities (except for the current Amnesia one) will have
        /// completed and any future activities will be denied.
        /// </summary>
        private void Pause(int timeoutMS, ILog log)
        {
            // Ensure only a single thread owns the pause lock.
            Monitor.Enter(pauseLock);

            try
            {
                // At this point the current thread has been granted the pauseLock and can start blocking future activities as well as
                // wait for any current activities to complete.

                lock (fieldsLock)
                {
                    // stop future activities from starting
                    paused = true;

                    // Wait for any activities that are currently executing to complete
                    int freeActivities = (CurrentThreadActivity != null ? 1 : 0);

                    if (activityCount > freeActivities)
                    {
                        // Let other threads know we're interested in knowing when we're idle and wait
                        activitiesDone = new AutoResetEvent(false);

                        // Take into account that the lock request may be occuring either from an existing activity
                        pendingActivities = activityCount - freeActivities;
                    }
                }

                // Wait for other request threads to complete
                if (activitiesDone != null)
                {
                    log.Write("Waiting for other amnesia activities to complete...");

                    bool signalReceived = activitiesDone.WaitOne(timeoutMS);
                    activitiesDone = null;

                    if(signalReceived)
                        log.Write("Other amnesia activities completed successfully.");
                    else
                        log.Write(string.Format("WARNING: Timeout ({0} milliseconds) reached while waiting for other amnesia activities to complete.", timeoutMS));
                }

                // Hold the pauseLock open until Resume()
            }
            catch (Exception)
            {
                // An unexpected error occurred so release the pauseLock
                Resume();
                throw;
            }
        }
开发者ID:vc3,项目名称:Amnesia,代码行数:56,代码来源:SessionTracker.cs

示例15: Execute

		public void Execute(int timeout, ILog log) 
		{
			log.Write("Executing {0} '{1}'", (this.IsParentModule ? "Project" : "Module"), this.Name);
			this.SavedObjects.Execute(timeout, log);
            this.ChildModules.Execute(timeout, log);

            foreach (string file in SavedObjects.SavedFiles)
            {
                if (!SavedFiles.Contains(file)) SavedFiles.Add(file);
            }

            foreach (string file in ChildModules.SavedFiles)
            {
                if (!SavedFiles.Contains(file)) SavedFiles.Add(file);
            }
        }
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:16,代码来源:ZeusModule.cs


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