diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-03-19 10:46:37 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-19 19:10:43 +0000 |
commit | 4b75ffd49db5655b0634d6dda0caeb4cd3d61851 (patch) | |
tree | 3c4ae762b9c7875eecad590c259204159c762ac9 /src/mongo/util/log_and_backoff.h | |
parent | eae3b334d1a69e2421de647db3f197aa2e3dd694 (diff) | |
download | mongo-4b75ffd49db5655b0634d6dda0caeb4cd3d61851.tar.gz |
SERVER-46411 Update logAndBackoff to have a logv2 style interface
Diffstat (limited to 'src/mongo/util/log_and_backoff.h')
-rw-r--r-- | src/mongo/util/log_and_backoff.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/util/log_and_backoff.h b/src/mongo/util/log_and_backoff.h index 39c5ef9d385..32a7af75663 100644 --- a/src/mongo/util/log_and_backoff.h +++ b/src/mongo/util/log_and_backoff.h @@ -31,18 +31,27 @@ #include "mongo/base/string_data.h" #include "mongo/logv2/log_component.h" +#include "mongo/logv2/log_detail.h" #include "mongo/logv2/log_severity.h" namespace mongo { +namespace log_backoff_detail { +void logAndBackoffImpl(size_t numAttempts); +} // namespace log_backoff_detail /** * Will log a message at 'logLevel' for the given 'logComponent' and will perform truncated * exponential backoff, with the backoff period based on 'numAttempts'. */ -void logAndBackoff(uint32_t logId, - logv2::LogComponent logComponent, - logv2::LogSeverity logLevel, +template <size_t N, typename... Args> +void logAndBackoff(int32_t logId, + logv2::LogComponent component, + logv2::LogSeverity severity, size_t numAttempts, - StringData message); + const char (&msg)[N], + const fmt::internal::named_arg<Args, char>&... args) { + logv2::detail::doLog(logId, severity, {component}, msg, args..., "attempts"_attr = numAttempts); + log_backoff_detail::logAndBackoffImpl(numAttempts); +} } // namespace mongo |