public static void logDatabaseContents(final LmdbEnv env,
                                           final Dbi<ByteBuffer> dbi,
                                           final Txn<ByteBuffer> txn,
                                           final Function<ByteBuffer, String> keyToStringFunc,
                                           final Function<ByteBuffer, String> valueToStringFunc,
                                           final Consumer<String> logEntryConsumer) {

        final StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(LogUtil.message("Dumping {} entries for database [{}]",
                getEntryCount(env, txn, dbi), new String(dbi.getName())));

        // loop over all DB entries
        try (CursorIterable<ByteBuffer> cursorIterable = dbi.iterate(txn, KeyRange.all())) {
            for (final KeyVal<ByteBuffer> keyVal : cursorIterable) {
                stringBuilder.append(LogUtil.message("\n  key: [{}] - value [{}]",
                        keyToStringFunc.apply(keyVal.key()),
                        valueToStringFunc.apply(keyVal.val())));
            }
        }
        logEntryConsumer.accept(stringBuilder.toString());
//        LOGGER.debug(stringBuilder.toString());
    }
Allocates a new direct {@link ByteBuffer} (of size bufferSize) and
serialises the object into that {@link ByteBuffer}

@return The newly allocated {@link ByteBuffer}
stroom-lmdb/src/main/java/stroom/lmdb/LmdbUtils.java