コード例 #1
0
ファイル: MMLog.cs プロジェクト: tomba/dwarrowdelf
        static LogEntry ReadEntry(int entryIndex)
        {
            byte[] buffer = s_buffer;

            if (buffer == null)
                s_buffer = buffer = new byte[MaxPayload];

            var reader = s_reader;

            if (reader == null)
                s_reader = reader = new BinaryReader(new MemoryStream(buffer));
            else
                reader.BaseStream.Seek(0, SeekOrigin.Begin);

            int len = ReadArray(entryIndex, buffer);

            var entry = new LogEntry(reader);
            return entry;
        }
コード例 #2
0
 public ViewableLogEntry(LogEntry logEntry)
 {
     this.DateTime = logEntry.DateTime;
     this.Tick = logEntry.Tick;
     this.Component = logEntry.Component;
     this.Thread = logEntry.Thread;
     this.Message = logEntry.Message;
 }
コード例 #3
0
ファイル: MMLog.cs プロジェクト: tomba/dwarrowdelf
        public static LogEntry[] ReadNewEntries(int sinceIdx, out int newIdx)
        {
            s_indexMutex.WaitOne();
            newIdx = GetCurrentIndex();
            s_indexMutex.ReleaseMutex();

            var idx = sinceIdx;
            //Console.WriteLine("old {0}, new {1}", idx, newIdx);

            var count = newIdx - idx;
            if (count < 0)
                count += MemoryMappedLog.MMLog.EntryCount;

            //Console.WriteLine("count {0}", count);

            LogEntry[] entries = new LogEntry[count];

            for (int i = 0; i < count; ++i)
            {
                var entry = ReadEntry(idx);

                //Console.WriteLine("{0,-5} {1,5}/{2,-5} : {3}, {4}, {5}", idx, i, count - 1, entry.DateTime.Ticks, entry.Flags, entry.Text);

                entries[i] = entry;

                idx = (idx + 1) % MemoryMappedLog.MMLog.EntryCount;
            }

            return entries;
        }
コード例 #4
0
 void OnMarkClicked(object sender, RoutedEventArgs e)
 {
     var entry = new LogEntry(DateTime.Now, 0, component: "Mark");
     Add(entry);
 }
コード例 #5
0
        public void Add(LogEntry entry)
        {
            var ve = new ViewableLogEntry(entry);

            if (m_debugCollection.Count > 0)
            {
                var last = m_debugCollection.Last();
                var td = ve.DateTime - last.DateTime;
                ve.TimeDiff = td;
            }

            m_debugCollection.Add(ve);

            var str = String.Format("{0} | {1}: {2}", entry.DateTime, entry.Component, entry.Message);

            if (m_logFile != null)
                m_logFile.WriteLine(str);

            if (m_netWriter != null)
                m_netWriter.WriteLine(str);

            if (m_logFile != null)
                m_logFile.Flush();

            while (m_debugCollection.Count > 500)
                m_debugCollection.RemoveAt(0);

            if (m_scrollToEnd)
                logListView.ScrollIntoView(ve);
        }
コード例 #6
0
ファイル: MMLog.cs プロジェクト: Fulborg/dwarrowdelf
        static LogEntry ReadEntry(int entryIndex)
        {
            var buffer = new byte[s_maxPayloadSize];
            int len = ReadArray(entryIndex, buffer);

            using (var r = new BinaryReader(new MemoryStream(buffer)))
            {
                var entry = new LogEntry(r);
                return entry;
            }
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: tomba/dwarrowdelf
 public ViewableLogEntry(LogEntry logEntry)
 {
     this.DateTime = logEntry.DateTime;
     switch (logEntry.EventType)
     {
         case TraceEventType.Critical:
             this.EventType = "C";
             break;
         case TraceEventType.Error:
             this.EventType = "E";
             break;
         case TraceEventType.Warning:
             this.EventType = "W";
             break;
         case TraceEventType.Information:
             this.EventType = "I";
             break;
         case TraceEventType.Verbose:
             this.EventType = "V";
             break;
         default:
             this.EventType = "";
             break;
     }
     this.Tick = logEntry.Tick;
     switch (logEntry.Component)
     {
         case LogComponent.Server:
             this.Component = "S";
             break;
         case LogComponent.Client:
             this.Component = "C";
             break;
         default:
             this.Component = "";
             break;
     }
     this.Thread = logEntry.Thread;
     this.Header = logEntry.Header;
     this.Message = logEntry.Message;
 }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: tomba/dwarrowdelf
 public void Add(LogEntry entry)
 {
     var ve = new ViewableLogEntry(entry);
     Add(ve);
 }