Example #1
0
        public void Write(DateTime time, LogLevel level, string source, string message)
        {
            if (stream == null)
            {
                return;
            }

            string line = LogUtility.Format(time, level, source, message);

            byte[] bytes = Encoding.UTF8.GetBytes(line);

            if (currentSize + bytes.Length + newLine.Length > MaximumSize)
            {
                Rollover();
            }

            lock (synchronizationLock)
            {
                currentSize += bytes.Length + newLine.Length;

                try
                {
                    stream.Write(bytes, 0, bytes.Length);
                    stream.Write(newLine, 0, newLine.Length);
                    stream.Flush();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(string.Format("Cannot write log line: {0}", e.Message));
                }
            }
        }
 public void Write(DateTime time, LogLevel level, string source, string message)
 {
     Debug.WriteLine(LogUtility.Format(time, level, source, message));
 }