Limit the length of the name retrieved from the environment
variable $LOGNAME or $USER. Sanitize it by removing whitespace
to benefit log file parsers. Double any embedded '%' characters
since this string will be embedded in a *printf format string.
Detect and warn about overflow when building the format string.