Example #1
0
        private void LogWriteToFile()
        {
            if (WriteFile != null)
            {
                WriteFile.Refresh();
            }

            if (WriteFile == null || WriteFile.Length >= 1024 * 1024)
            {
                if (WriteStream != null)
                {
                    WriteStream.Dispose();
                }

                if (!Directory.Exists(m_Directory))
                {
                    Directory.CreateDirectory(m_Directory);
                }

                var fileName = $"{m_Directory}\\{m_CategoryName}_{DateTime.Now.ToString(m_FileTemplate)}.txt";
                WriteStream = new StreamWriter(File.OpenWrite(fileName), Encoding.Unicode);
                WriteFile   = new FileInfo(fileName);
            }

            while (m_LogQueue.TryDequeue(out string log))
            {
                WriteStream.Write(log);
            }
            WriteStream.Flush();
        }
Example #2
0
        public void Write(string input)
        {
            if (!CanWrite)
            {
                return;
            }
            WriteStream.WriteLine(input);
            WriteStream.Flush();

            HBuffer.Add(input);
            ReadOffset = 0;
        }
Example #3
0
            public void OpenStream()
            {
                if (WriteStream != null)
                {
                    WriteStream.Flush();
                    WriteStream.Close();
                    WriteStream.Dispose();
                    WriteStream = null;
                }

                WriteStream = new FileStream(FilePath, FileMode.Create, FileAccess.Write, FileShare.None);
                TimeStarted = Environment.TickCount;
            }
Example #4
0
            public void OpenStream()
            {
                if (WriteStream != null)
                {
                    WriteStream.Flush();
                    WriteStream.Close();
                    WriteStream.Dispose();
                    WriteStream = null;
                }

                WriteStream = File.Open(FilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                TimeStarted = Environment.TickCount;
            }
Example #5
0
        /// <summary>
        /// See <code>LoggerBase.WriteLogLine</code>
        ///
        /// Write the log line to the stream
        /// </summary>
        /// <param name="exception_">The exception (if any) to log</param>
        /// <param name="level_">The log level to write at</param>
        /// <param name="content_">The log message</param>
        /// <param name="args_">Any additional data to include in the log</param>
        protected override void WriteLogLine(Exception exception_, LogLevel level_, string content_, params object[] args_)
        {
            var logLine = CreateLogLine(exception_, level_, content_, args_);

            lock (WriteStreamLock)
            {
                if (null == WriteStream)
                {
                    return;
                }

                var bytesToWrite = LogEncoding.GetBytes(logLine);
                WriteStream.Write(bytesToWrite, 0, bytesToWrite.Length);
                WriteStream.Flush();
            }
        }
Example #6
0
            protected virtual void Dispose(bool disposing)
            {
                if (disposed)
                {
                    return;
                }

                if (disposing)
                {
                    if (WriteStream != null)
                    {
                        WriteStream.Flush();
                        WriteStream.Close();
                        WriteStream.Dispose();
                        WriteStream = null;
                    }
                }
                disposed = true;
            }
Example #7
0
 public override void Flush()
 {
     WriteStream.Flush();
 }
Example #8
0
 public void Flush()
 {
     EnsureObjectNotDisposed();
     WriteStream.Flush();
 }
 public virtual void Flush()
 {
     WriteStream.Flush();
 }