* fStartedNewLine is a state variable held by the calling context that will * suppress printing of the timestamp when multiple calls are made that don't * end in a newline. Initialize it to true, and hold it, in the calling context. */
| 257 | * end in a newline. Initialize it to true, and hold it, in the calling context. |
| 258 | */ |
| 259 | static std::string LogTimestampStr(const std::string &str, bool *fStartedNewLine) |
| 260 | { |
| 261 | string strStamped; |
| 262 | |
| 263 | if (!fLogTimestamps) |
| 264 | return str; |
| 265 | |
| 266 | if (*fStartedNewLine) |
| 267 | strStamped = DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()) + ' ' + str; |
| 268 | else |
| 269 | strStamped = str; |
| 270 | |
| 271 | if (!str.empty() && str[str.size()-1] == '\n') |
| 272 | *fStartedNewLine = true; |
| 273 | else |
| 274 | *fStartedNewLine = false; |
| 275 | |
| 276 | return strStamped; |
| 277 | } |
| 278 | |
| 279 | int LogPrintStr(const std::string &str) |
| 280 | { |
no test coverage detected