Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit a665b67

Browse files
committed
Only show LastCommand info if it exists and verbose logging is not disabled
1 parent a152e52 commit a665b67

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,19 @@ private bool Reconnect()
274274
private RedisResponseException CreateResponseError(string error)
275275
{
276276
DeactivatedAt = DateTime.UtcNow;
277-
string safeLastCommand = string.IsNullOrEmpty(Password) ? lastCommand : (lastCommand ?? "").Replace(Password, "");
278277

279-
var throwEx = new RedisResponseException(
280-
string.Format("{0}, sPort: {1}, LastCommand: {2}",
281-
error, clientPort, safeLastCommand));
282-
log.Error(throwEx.Message);
278+
if (!RedisConfig.DisableVerboseLogging)
279+
{
280+
var safeLastCommand = string.IsNullOrEmpty(Password)
281+
? lastCommand
282+
: (lastCommand ?? "").Replace(Password, "");
283+
284+
if (!string.IsNullOrEmpty(safeLastCommand))
285+
error = string.Format("{0}, LastCommand:'{1}', srcPort:{2}", error, safeLastCommand, clientPort);
286+
}
287+
288+
var throwEx = new RedisResponseException(error);
289+
log.Error(error);
283290
throw throwEx;
284291
}
285292

0 commit comments

Comments
 (0)