Add printf format checking to printf-style log constructors.

This improves safety by diagnosing format string mismatches under both Clang and GCC.

This is the PR for #2833.