Пример #1
0
 public void Save(LogFileWriter fileWriter)
 {
     foreach (var message in AllMessages)
     {
         if (message.Message != null)
         {
             fileWriter.Write(message.Message);
         }
     }
 }
Пример #2
0
 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);
        }
        /// <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);
                }
            }
        }
        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);
        }
 public void Save(LogFileWriter fileWriter)
 {
     foreach (var message in AllMessages)
     {
         if (message.Message != null)
         {
             fileWriter.Write(message.Message);
         }
     }
 }
 public void Save(string outputFileName)
 {
     using (var fileWriter = new LogFileWriter(outputFileName))
     {
         foreach (var owner in m_owners.Values)
         {
             owner.Save(fileWriter);
         }
     }
 }