log: make the logging functions handle > 1024 bytes correctly
We simply truncate the output if it's larger than our static
buffer. Make it dynamically allocated instead, and ensure that
we loop correctly to handle the full amount asked for.
This fixes a problem with truncated output. One example is
json output, with file names (for multiple files) that are
larger than 1024 bytes. With the truncated output, we would
truncate the file name and hence also miss the terminating
'"'. The latter means the json was no longer valid, either.
Signed-off-by: Jens Axboe <axboe@fb.com>