Inheritance: IDisposable
コード例 #1
0
ファイル: LogFileCompactor.cs プロジェクト: xj0229/gsf
 public void Save(LogFileWriter fileWriter)
 {
     foreach (var message in AllMessages)
     {
         if (message.Message != null)
         {
             fileWriter.Write(message.Message);
         }
     }
 }
コード例 #2
0
ファイル: LogFileCompactor.cs プロジェクト: xj0229/gsf
 public void Save(string outputFileName)
 {
     using (var fileWriter = new LogFileWriter(outputFileName))
     {
         foreach (var owner in m_owners.Values)
         {
             owner.Save(fileWriter);
         }
     }
 }
コード例 #3
0
        /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
        /// <filterpriority>2</filterpriority>
        public void Dispose()
        {
            m_flushTask.Dispose();
            lock (m_syncRoot)
            {
                if (m_writer != null)
                {
                    string fileName = m_writer.FileName;
                    m_writer.Dispose();
                    m_writer = null;

                    OnNewFileComplete(fileName);
                }
            }
        }
コード例 #4
0
        private void WriteLogMessage(LogMessage log)
        {
            //Rollover a file if over 500KB in size, over 50000 records, or older than 12 hours.
            //Ideally, 500KB will always come first.
            if (m_writer != null && (m_writer.LogSize > 500 * 1024 || m_writer.LogCount >= 50000 || m_fileAge.Elapsed.TotalHours > 12))
            {
                string fileName = m_writer.FileName;
                m_writer.Dispose();
                m_writer = null;
                OnNewFileComplete(fileName);
            }

            if (m_writer == null)
            {
                m_fileAge.Restart();
                try
                {
                    if (m_maxFileCount > 0)
                    {
                        string[] files = Directory.GetFiles(m_path, "*.logz");
                        if (files.Length > m_maxFileCount)
                        {
                            Array.Sort(files);

                            for (int x = 0; x < files.Length - m_maxFileCount; x++)
                            {
                                File.Delete(files[x]);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
                string file = $"{DateTime.UtcNow.ToString("yyyyMMdd-HHmmss-ffffff")} - {m_processName} - {m_fileSequenceNumber}.logz";
                m_fileSequenceNumber++;
                var fileName = Path.Combine(m_path, file);
                m_writer = new LogFileWriter(fileName);
            }

            m_writer.Write(log, false);
        }
コード例 #5
0
        /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
        /// <filterpriority>2</filterpriority>
        public void Dispose()
        {
            m_flushTask.Dispose();
            lock (m_syncRoot)
            {
                if (m_writer != null)
                {
                    string fileName = m_writer.FileName;
                    m_writer.Dispose();
                    m_writer = null;

                    OnNewFileComplete(fileName);
                }
            }
        }
コード例 #6
0
        private void WriteLogMessage(LogMessage log)
        {
            //Rollover a file if over 500KB in size, over 50000 records, or older than 12 hours.
            //Ideally, 500KB will always come first.
            if (m_writer != null && (m_writer.LogSize > 500 * 1024 || m_writer.LogCount >= 50000 || m_fileAge.Elapsed.TotalHours > 12))
            {
                string fileName = m_writer.FileName;
                m_writer.Dispose();
                m_writer = null;
                OnNewFileComplete(fileName);
            }

            if (m_writer == null)
            {
                m_fileAge.Restart();
                try
                {
                    if (m_maxFileCount > 0)
                    {
                        string[] files = Directory.GetFiles(m_path, "*.logz");
                        if (files.Length > m_maxFileCount)
                        {
                            Array.Sort(files);

                            for (int x = 0; x < files.Length - m_maxFileCount; x++)
                            {
                                File.Delete(files[x]);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
                string file = $"{DateTime.UtcNow.ToString("yyyyMMdd-HHmmss-ffffff")} - {m_processName} - {m_fileSequenceNumber}.logz";
                m_fileSequenceNumber++;
                var fileName = Path.Combine(m_path, file);
                m_writer = new LogFileWriter(fileName);
            }

            m_writer.Write(log, false);
        }
コード例 #7
0
 public void Save(LogFileWriter fileWriter)
 {
     foreach (var message in AllMessages)
     {
         if (message.Message != null)
         {
             fileWriter.Write(message.Message);
         }
     }
 }
コード例 #8
0
 public void Save(string outputFileName)
 {
     using (var fileWriter = new LogFileWriter(outputFileName))
     {
         foreach (var owner in m_owners.Values)
         {
             owner.Save(fileWriter);
         }
     }
 }