When calling snprintf, supply the full buffer size instead of
one byte less.
When using the returned length from vsnprintf for logging, don't write
more than the actual buffer size (minus one for the trailing \0), in
case the formatted string was truncated.