private void CreateContext(Encoding encoding, int bufferSegmentSize, int bufferSegmentCount = 512) { _segmentProvider = new BufferSegmentProvider(bufferSegmentCount, bufferSegmentSize); _writer = new UnsafeBinaryWriter(encoding); _writer.SetBufferSegmentProvider(_segmentProvider); _reader = _segmentProvider.GetBinaryReader(encoding); }
public void SetUp() { _bufferSegmentProvider = new BufferSegmentProvider(1024, 1024); _logEvent = new LogEvent(_bufferSegmentProvider.GetSegment()); _output = new StringBuffer(128) { Culture = CultureInfo.InvariantCulture }; }
public void should_log_to_file() { var bytes = new byte[256]; var message = "Test log message"; var byteLength = Encoding.Default.GetBytes(message, 0, message.Length, bytes, 0); var bufferSegmentProvider = new BufferSegmentProvider(1024, 1024); var logEvent = new LogEvent(bufferSegmentProvider.GetSegment()); logEvent.Initialize(Level.Info, new Log(null, "TestLog")); _appender.WriteEvent(logEvent, bytes, byteLength); _appender.Flush(); var written = GetLastLine(); Check.That(written).IsEqualTo($"{logEvent.Timestamp.Date:yyyy-MM-dd} - {logEvent.Timestamp.TimeOfDay.ToString(@"hh\:mm\:ss\.fff")} - {Thread.CurrentThread.ManagedThreadId} - Info - TestLog || " + message); }
public void SetUp() { _bufferSegmentProvider = new BufferSegmentProvider(32, _defaultSegmentSize); }