Esempio n. 1
0
 public void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
 {
     Array.Copy(messageBytes, _messages[_count].StartTimestampInChars, messageLength);
     _messages[_count].MessageLength = messageLength;
     _messages[_count].EndTimestamp  = Stopwatch.GetTimestamp();
     _count++;
 }
Esempio n. 2
0
        public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
        {
            var stream = _stream;

            if (stream == null)
            {
                return;
            }

            if (messageLength + 1 >= messageBytes.Length)
            {
                throw new ApplicationException($"{nameof(messageBytes)} must be big enough to also contain the new line characters");
            }

            WritePrefix(stream, logEventHeader);

            NewlineBytes.CopyTo(messageBytes, messageLength);
            messageLength += NewlineBytes.Length;

            stream.Write(messageBytes, 0, messageLength);

            if (AutoFlush)
            {
                stream.Flush();
            }

            _currentFileSize = (int)stream.Length;
            CheckRollFile();
        }
Esempio n. 3
0
        protected int WriteEventToStream(Stream stream, ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
        {
            var bytesWritten = 0;

            bytesWritten += _prefixWriter.WritePrefix(stream, logEventHeader, _encoding);
            bytesWritten += WriteLine(stream, messageBytes, messageLength);
            return(bytesWritten);
        }
Esempio n. 4
0
        public void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
        {
            if (_captureLoggedMessages)
            {
                LoggedMessages.Add(Encoding.ASCII.GetString(messageBytes, 0, messageLength));
            }

            if (++_messageCount == _messageCountTarget)
            {
                _signal.Set();
            }
        }
        public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
        {
            var stream = _stream;

            if (stream == null)
            {
                return;
            }

            _fileSize += WriteEventToStream(stream, logEventHeader, messageBytes, messageLength);
            CheckRollFile(logEventHeader.Timestamp);
        }
Esempio n. 6
0
        public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
        {
            Console.BackgroundColor = ConsoleColor.Black;
            switch (logEventHeader.Level)
            {
            case Level.Fatal:
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BackgroundColor = ConsoleColor.White;
                break;

            case Level.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                break;

            case Level.Warn:
                Console.ForegroundColor = ConsoleColor.Yellow;
                break;

            case Level.Info:
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case Level.Debug:
                Console.ForegroundColor = ConsoleColor.Gray;
                break;

            case Level.Verbose:
                Console.ForegroundColor = ConsoleColor.Gray;
                break;

            case Level.Finest:
                Console.ForegroundColor = ConsoleColor.Gray;
                break;

            default:
                Console.ForegroundColor = ConsoleColor.White;
                break;
            }

            WritePrefix(_output, logEventHeader);

            NewlineBytes.CopyTo(messageBytes, messageLength);
            messageLength += NewlineBytes.Length;

            _output.Write(messageBytes, 0, messageLength);
        }
Esempio n. 7
0
        protected unsafe void WritePrefix(Stream stream, ILogEventHeader logEventHeader)
        {
            _stringBuffer.Clear();
            _stringBuffer.AppendFormat(_prefixFormat,
                                       logEventHeader.Timestamp.Date,
                                       logEventHeader.Timestamp.TimeOfDay,
                                       logEventHeader.ThreadId,
                                       LevelStringCache.GetLevelString(logEventHeader.Level),
                                       logEventHeader.Name);

            int bytesWritten;

            fixed(byte *buf = _tempBytes)
            bytesWritten = _stringBuffer.CopyTo(buf, _tempBytes.Length, 0, _stringBuffer.Count, _encoding);

            stream.Write(_tempBytes, 0, bytesWritten);
        }
Esempio n. 8
0
 public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
 {
 }
Esempio n. 9
0
 public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
 {
     WrittenEventCount++;
     base.WriteEvent(logEventHeader, messageBytes, messageLength);
 }
Esempio n. 10
0
 public abstract void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength);
Esempio n. 11
0
 public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength)
 => WriteEventToStream(_stream, logEventHeader, messageBytes, messageLength);