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++; }
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(); }
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); }
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); }
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); }
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); }
public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength) { }
public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength) { WrittenEventCount++; base.WriteEvent(logEventHeader, messageBytes, messageLength); }
public abstract void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength);
public override void WriteEvent(ILogEventHeader logEventHeader, byte[] messageBytes, int messageLength) => WriteEventToStream(_stream, logEventHeader, messageBytes, messageLength);