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

Commit 6f77f03

Browse files
committed
Update debug logging to log when ILog.IsDebugEnabled
1 parent d67c30a commit 6f77f03

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ protected bool SendCommand(params byte[][] cmdWithBinaryArgs)
263263
if (__requestsPerHour % 20 == 0)
264264
LicenseUtils.AssertValidUsage(LicenseFeature.Redis, QuotaType.RequestsPerHour, __requestsPerHour);
265265

266-
CmdLog(cmdWithBinaryArgs);
266+
if (log.IsDebugEnabled)
267+
CmdLog(cmdWithBinaryArgs);
267268

268269
//Total command lines count
269270
WriteAllToSendBuffer(cmdWithBinaryArgs);
@@ -498,7 +499,6 @@ protected void Log(string fmt, params object[] args)
498499
log.DebugFormat("{0}", string.Format(fmt, args).Trim());
499500
}
500501

501-
[Conditional("DEBUG")]
502502
protected void CmdLog(byte[][] args)
503503
{
504504
var sb = new StringBuilder();
@@ -526,7 +526,8 @@ protected void ExpectSuccess()
526526

527527
var s = ReadLine();
528528

529-
Log((char)c + s);
529+
if (log.IsDebugEnabled)
530+
Log((char)c + s);
530531

531532
if (c == '-')
532533
throw CreateResponseError(s.StartsWith("ERR") && s.Length >= 4 ? s.Substring(4) : s);
@@ -540,7 +541,8 @@ private void ExpectWord(string word)
540541

541542
var s = ReadLine();
542543

543-
Log((char)c + s);
544+
if (log.IsDebugEnabled)
545+
Log((char)c + s);
544546

545547
if (c == '-')
546548
throw CreateResponseError(s.StartsWith("ERR") ? s.Substring(4) : s);
@@ -557,7 +559,8 @@ private string ExpectCode()
557559

558560
var s = ReadLine();
559561

560-
Log((char)c + s);
562+
if (log.IsDebugEnabled)
563+
Log((char)c + s);
561564

562565
if (c == '-')
563566
throw CreateResponseError(s.StartsWith("ERR") ? s.Substring(4) : s);
@@ -583,7 +586,8 @@ public long ReadInt()
583586

584587
var s = ReadLine();
585588

586-
Log("R: {0}", s);
589+
if (log.IsDebugEnabled)
590+
Log("R: {0}", s);
587591

588592
if (c == '-')
589593
throw CreateResponseError(s.StartsWith("ERR") ? s.Substring(4) : s);
@@ -605,7 +609,8 @@ public long ReadLong()
605609

606610
var s = ReadLine();
607611

608-
Log("R: {0}", s);
612+
if (log.IsDebugEnabled)
613+
Log("R: {0}", s);
609614

610615
if (c == '-')
611616
throw CreateResponseError(s.StartsWith("ERR") ? s.Substring(4) : s);
@@ -627,7 +632,8 @@ private byte[] ReadData()
627632

628633
private byte[] ParseSingleLine(string r)
629634
{
630-
Log("R: {0}", r);
635+
if (log.IsDebugEnabled)
636+
Log("R: {0}", r);
631637
if (r.Length == 0)
632638
throw CreateResponseError("Zero length response");
633639

@@ -679,7 +685,8 @@ private byte[][] ReadMultiData()
679685
throw CreateResponseError("No more data");
680686

681687
var s = ReadLine();
682-
Log("R: {0}", s);
688+
if (log.IsDebugEnabled)
689+
Log("R: {0}", s);
683690

684691
switch (c)
685692
{
@@ -727,7 +734,8 @@ private object ReadDeeplyNestedMultiDataItem()
727734
throw CreateResponseError("No more data");
728735

729736
var s = ReadLine();
730-
Log("R: {0}", s);
737+
if (log.IsDebugEnabled)
738+
Log("R: {0}", s);
731739

732740
switch (c)
733741
{
@@ -765,7 +773,8 @@ internal int ReadMultiDataResultCount()
765773
throw CreateResponseError("No more data");
766774

767775
var s = ReadLine();
768-
Log("R: {0}", s);
776+
if (log.IsDebugEnabled)
777+
Log("R: {0}", s);
769778
if (c == '-')
770779
throw CreateResponseError(s.StartsWith("ERR") ? s.Substring(4) : s);
771780
if (c == '*')

0 commit comments

Comments
 (0)