Skip to content

Commit 2987c76

Browse files
committed
feat redis: fix asserts
commit_hash:1804dc9f92c18e82b3894f7278054f0cefa9e10a
1 parent a600511 commit 2987c76

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

redis/src/storages/redis/impl/cluster_sentinel_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ std::shared_ptr<const std::vector<std::string>> MakeShardNames() {
140140

141141
void InvokeCommand(CommandPtr command, ReplyPtr&& reply, const logging::LogExtra& log_extra) {
142142
UASSERT(reply);
143+
UASSERT(command);
143144

144145
if (reply->server_id.IsAny()) {
145146
reply->server_id = CommandControlImpl{command->control}.force_server_id;

universal/src/logging/log_helper.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ void LogHelper::DoLog() noexcept {
149149
}
150150

151151
void LogHelper::InternalLoggingError(std::string_view message) noexcept {
152+
std::string exc_info;
152153
try {
154+
exc_info = boost::current_exception_diagnostic_information();
153155
// Use fmt::format to output the message without interleaving with other logs.
154-
std::fputs(
155-
fmt::format("LogHelper: {}. {}\n", message, boost::current_exception_diagnostic_information()).c_str(),
156-
stderr
157-
);
156+
std::fputs(fmt::format("LogHelper: {}. {}\n", message, exc_info).c_str(), stderr);
158157
} catch (...) {
159158
// ignore
159+
exc_info = "unknown"; // fits into SSO
160160
}
161161
pimpl_->MarkAsBroken();
162-
UASSERT_MSG(false, message);
162+
UASSERT_MSG(false, fmt::format("{}: {}", message, exc_info));
163163
}
164164

165165
impl::TagWriter LogHelper::GetTagWriter() { return impl::TagWriter{*this}; }
@@ -271,7 +271,7 @@ LogHelper& LogHelper::PutTag(std::string_view key, const LogExtra::Value& value)
271271
try {
272272
pimpl_->AddTag(key, value);
273273
} catch (...) {
274-
InternalLoggingError("Failed to extend log with LogExtra&&");
274+
InternalLoggingError("Failed to extend log with Value");
275275
}
276276
return *this;
277277
}
@@ -280,7 +280,7 @@ LogHelper& LogHelper::PutSwTag(std::string_view key, std::string_view value) noe
280280
try {
281281
pimpl_->AddTag(key, value);
282282
} catch (...) {
283-
InternalLoggingError("Failed to extend log with LogExtra&&");
283+
InternalLoggingError("Failed to extend log with std::string_view");
284284
}
285285
return *this;
286286
}

0 commit comments

Comments
 (0)