void Start() { // No level will log. DLogger.All("I will not show up in the console because logging is off."); DLogger.Trace("I will not show up in the console because logging is off."); DLogger.Debug("I will not show up in the console because logging is off."); DLogger.Info("I will not show up in the console because logging is off."); DLogger.Warn("I will not show up in the console because logging is off."); DLogger.Error("I will not show up in the console because logging is off."); DLogger.Fatal("I will not show up in the console because logging is off."); }
private void CloseIO() { try { _odbWriter.Dispose(); } catch (IOException e) { DLogger.Error("NonBufferedFileIO" + e); throw new OdbRuntimeException(NDatabaseError.InternalError.AddParameter(e.Message), e); } _odbWriter = null; }
public void Register_logger_and_check_logged_messages() { var logger = new FakeLogger(); OdbConfiguration.RegisterLogger(logger); DLogger.Info("info"); DLogger.Debug("debug"); DLogger.Warning("warning"); DLogger.Error("error"); Assert.That(logger.GetInfoMessage(), Is.EqualTo("info")); Assert.That(logger.GetDebugMessage(), Is.EqualTo("debug")); Assert.That(logger.GetWarningMessage(), Is.EqualTo("warning")); Assert.That(logger.GetErrorMessage(), Is.EqualTo("error")); }
internal static WriteAction Read(IFileSystemInterface fsi) { try { var position = fsi.ReadLong(); var size = fsi.ReadInt(); var bytes = fsi.ReadBytes(size); var writeAction = new WriteAction(position, bytes); if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug(string.Format("Transaction WriteAction: Loading Write Action at {0} => {1}", fsi.GetPosition(), writeAction)); } return(writeAction); } catch (OdbRuntimeException) { DLogger.Error(string.Format("Transaction WriteAction: error reading write action at position {0}", fsi.GetPosition())); throw; } }
private int ManageBufferForNewPosition(long newPosition, bool isReading, int size) { var bufferIndex = _buffer.GetBufferIndexForPosition(newPosition, size); if (bufferIndex != -1) { return(bufferIndex); } // checks if there is any overlapping buffer _overlappingBuffers = GetOverlappingBuffers(newPosition, _buffer.Size); // Choose the first overlapping buffer bufferIndex = _overlappingBuffers[0]; if (_overlappingBuffers[1] != -1 && bufferIndex == _currentBufferIndex) { bufferIndex = _overlappingBuffers[1]; } if (bufferIndex == -1) { bufferIndex = _nextBufferIndex; _nextBufferIndex = (_nextBufferIndex + 1) % MultiBuffer.NumberOfBuffers; if (bufferIndex == _currentBufferIndex) { bufferIndex = _nextBufferIndex; _nextBufferIndex = (_nextBufferIndex + 1) % MultiBuffer.NumberOfBuffers; } Flush(bufferIndex); } _currentBufferIndex = bufferIndex; var length = Length; if (isReading && newPosition >= length) { var message = string.Concat("MultiBufferedFileIO: End Of File reached - position = ", newPosition.ToString(), " : Length = ", length.ToString()); DLogger.Error(message); throw new OdbRuntimeException( NDatabaseError.EndOfFileReached.AddParameter(newPosition).AddParameter(length)); } // The buffer must be initialized with real data, so the first thing we // must do is read data from file and puts it in the array long nread = _buffer.Size; // if new position is in the file if (newPosition < length) { // We are in the file, we are updating content. to create the // buffer, we first read the content of the file // Actually loads data from the file to the buffer nread = _nonBufferedFileIO.Read(newPosition, _buffer.Buffers[bufferIndex], _buffer.Size); _buffer.SetCreationDate(bufferIndex, OdbTime.GetCurrentTimeInTicks()); } else { _nonBufferedFileIO.SetCurrentPosition(newPosition); } // If we are in READ, sets the size equal to what has been read var endPosition = isReading ? newPosition + nread : newPosition + _buffer.Size; _buffer.SetPositions(bufferIndex, newPosition, endPosition); _currentPositionWhenUsingBuffer = newPosition; return(bufferIndex); }