Exemplo n.º 1
0
        public bool Log(string strlog, LogType type)
        {
            LogEventArgs logent = new LogEventArgs(strlog, type);

            //Add to list and fire event
            m_latest.Add(logent);

            string logline = String.Format("[{0}] TYPE: {1} MESSAGE: {2}",
                logent.Time, logent.Type, logent.Message);
            m_logfile.WriteLine(logline);
            m_logfile.Flush();

            LogEnterred(this, logent);
            return true;
        }
Exemplo n.º 2
0
        private void AddToLatest(LogEventArgs logent)
        {
            //Remove from latest at top
            if (m_latest.Count > m_latesize)
                m_latest.RemoveAt(m_latest.Count-1);

            m_latest.Insert(0, logent);
        }
Exemplo n.º 3
0
        private void Logger_LogEnterred(object sender, LogEventArgs args)
        {
            ListViewItem item = new ListViewItem();

            lock (this) {
                switch (args.Type) {
                    case TestLogger.LogType.INFORMATION:
                        item.ImageIndex = 1;
                        item.Text = "Info";
                        break;
                    case TestLogger.LogType.WARNING:
                        item.ImageIndex = 2;
                        item.Text = "Warning";
                        break;
                    case TestLogger.LogType.ERROR:
                        item.ImageIndex = 0;
                        item.Text = "Error";
                        break;
                }

                item.SubItems.Add(args.Time.ToString());
                item.SubItems.Add(args.Message);

                lstMessages.Items.Add(item);
                lstMessages.Refresh();
            }
        }