| 1663 | bool logErrorReported = false; |
| 1664 | |
| 1665 | void sayf(int indent, const char* fmt, ...) |
| 1666 | { |
| 1667 | static char indentBuffer[] = " "; |
| 1668 | static char buf[2048]; |
| 1669 | |
| 1670 | indentBuffer[indent] = '\0'; |
| 1671 | |
| 1672 | va_list arglist; |
| 1673 | va_start(arglist, fmt); |
| 1674 | vsprintf(buf, fmt, arglist); |
| 1675 | va_end(arglist); |
| 1676 | |
| 1677 | if (*logOut) { |
| 1678 | (*logOut) << indentBuffer << buf; |
| 1679 | } |
| 1680 | else if (!logErrorReported) { |
| 1681 | std::printf("Note: Error writing to log file. Future output will appear only on stdout\n"); |
| 1682 | logErrorReported = true; |
| 1683 | } |
| 1684 | std::printf("%s%s", indentBuffer, buf); |
| 1685 | |
| 1686 | indentBuffer[indent] = ' '; |
| 1687 | } |
| 1688 | |
| 1689 | |
| 1690 | // Returns a formatted timestamp. |