Used together with PARAM to VLOG calls made to the stream. Intended to be used like this: VLOG(1) << CallStr("MyFunction", this, {PARAM(a), PARAM(b)}); where a and b are the parameters to MyFunction. See VLOG_CALL for a short-hand for this. This way of doing it saves a tremendous amount of boilerplate code given how many functions there are on Stream and how many parameters they each have.
| 232 | // a tremendous amount of boilerplate code given how many functions |
| 233 | // there are on Stream and how many parameters they each have. |
| 234 | string CallStr(const char *function_name, Stream *stream, |
| 235 | std::vector<std::pair<const char *, string>> params) { |
| 236 | // Do not call this function unless VLOG is on since just |
| 237 | // constructing all the strings in params is expensive. |
| 238 | CHECK(VLOG_IS_ON(1)); |
| 239 | |
| 240 | string str = absl::StrCat(stream->DebugStreamPointers(), |
| 241 | " Called Stream::", function_name, "("); |
| 242 | const char *separator = ""; |
| 243 | for (const auto ¶m : params) { |
| 244 | absl::StrAppend(&str, separator, param.first, "=", param.second); |
| 245 | separator = ", "; |
| 246 | } |
| 247 | absl::StrAppend(&str, ")"); |
| 248 | if (VLOG_IS_ON(10)) { |
| 249 | absl::StrAppend(&str, " ", port::CurrentStackTrace(), "\n"); |
| 250 | } |
| 251 | return str; |
| 252 | } |
| 253 | |
| 254 | // Use this macro to avoid having to type every parameter twice to log |
| 255 | // it with VLOG and CallStr. |
nothing calls this directly
no test coverage detected