logging.c: update strrep function from my latest gist version.
logging.c: update strrep function from my latest gist version.

The changes are defensive, guarding against size_t arithmetic
overflows and malloc failures.

dhess/echoev