public void ActivateLog() { byte[] buffer = new byte[1024 * 1024 * 10]; LogTunnel tunnelLog; m_log = tunnelLog = CreateLog(); m_cfl = new ContinuesBinaryFileLogger(new InMemoryStreamProvider(new MemoryStream(buffer)), new SyncSubmitLogEntryFactory(), BufferPoolFactory.Instance); m_cfl.AttachToTunnelLog(tunnelLog); var readerFactory = new WhitelogBinaryReaderFactory(); readerFactory.RegisterReaderFactory(new ExpandableLogReaderFactory()); m_testConsumer = new TestConsumer(); m_logReader = readerFactory.GetLogReader(new MemoryStream(buffer), m_testConsumer); }
public void OpenFile(string filePath) { var readerFactory = new WhitelogBinaryReaderFactory(); readerFactory.RegisterReaderFactory(new ExpandableLogReaderFactory()); m_strem = System.IO.File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); var whitelogConsumer = new WhiteLogConsumer(); var logReader = readerFactory.GetLogReader(m_strem, whitelogConsumer); m_timer = new Timer(); m_timer.Interval = (int)TimeSpan.FromMilliseconds(100).TotalMilliseconds; m_timer.Tick += (o, args) => { if (!m_disposed) { logReader.TryRead(); } }; whitelogConsumer.ItemAdded += (o, eventData) => { if (eventData.IsRootItem) { m_logTreeView.AddObject(eventData.LogNode); } else { m_logTreeView.RefreshObject(eventData.LogNode); m_logTreeView.Expand(eventData.LogNode); } }; m_logTreeView.BeginUpdate(); logReader.TryRead(); m_logTreeView.EndUpdate(); m_timer.Start(); }