/** * Drains the ByteBufferDestination's buffer into the destination. By default this calls * {@link OutputStreamManager#write(byte[], int, int, boolean)} with the buffer contents. * The underlying stream is not {@linkplain OutputStream#flush() flushed}. * * @see #flushDestination() * @since 2.6 */ protected synchronized void flushBuffer(final ByteBuffer buf) { buf.flip(); if (buf.remaining() > 0) { writeToDestination(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining()); } buf.clear(); }
super.writeToDestination(bytes, offset, length); super.writeToDestination(bytes, offset, length);
/** * Some output streams synchronize writes while others do not. Synchronizing here insures that * log events won't be intertwined. * @param bytes The serialized Log event. * @param offset The offset into the byte array. * @param length The number of bytes to write. * @param immediateFlush flushes immediately after writing. * @throws AppenderLoggingException if an error occurs. */ protected synchronized void write(final byte[] bytes, final int offset, final int length, final boolean immediateFlush) { if (immediateFlush && byteBuffer.position() == 0) { writeToDestination(bytes, offset, length); flushDestination(); return; } if (length >= byteBuffer.capacity()) { // if request length exceeds buffer capacity, flush the buffer and write the data directly flush(); writeToDestination(bytes, offset, length); } else { if (length > byteBuffer.remaining()) { flush(); } byteBuffer.put(bytes, offset, length); } if (immediateFlush) { flush(); } }