Skip to content

Commit

Permalink
Fix formatting of Atomic log commands
Browse files Browse the repository at this point in the history
- Use either hexa or pretty print depending on the mutation type
- For commands that usually take integers, also display the decimal value of the parameter
  • Loading branch information
KrzysFR committed Jun 5, 2020
1 parent 5ed5cd1 commit 7cf684c
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions FoundationDB.Client/Tracing/FdbTransactionLog.Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public SetCommand(Slice key, Slice value)

public override string GetArguments(KeyResolver resolver)
{
return string.Concat(resolver.Resolve(this.Key), " = ", this.Value.ToString("K"));
return string.Concat(resolver.Resolve(this.Key), " = ", this.Value.ToString("V"));
}

}
Expand Down Expand Up @@ -571,7 +571,34 @@ public override string ToString(KeyResolver? resolver)
resolver ??= KeyResolver.Default;
var sb = new StringBuilder();
if (this.Snapshot) sb.Append("Snapshot.");
sb.Append("Atomic_").Append(this.Mutation.ToString()).Append(' ').Append(resolver.Resolve(GetUserKey())).Append(", <").Append(GetUserValue().ToHexaString(' ')).Append('>');

// Depending on the type of mutations, the value is either known to be binary, or could be anything...
var value = GetUserValue();
string str;
string? suffix = null;
switch (this.Mutation)
{
case FdbMutationType.VersionStampedKey:
{
str = value.ToString("V");
break;
}
default:
{
str = "<" + value.ToHexaString(' ') + ">";
switch (value.Count)
{
case 4:
suffix = " (" + value.ToInt32() + ")";
break;
case 8:
suffix = " (" + value.ToInt64() + ")";
break;
}
break;
}
}
sb.Append("Atomic_").Append(this.Mutation.ToString()).Append(' ').Append(resolver.Resolve(GetUserKey())).Append(", ").Append(str).Append(suffix);
return sb.ToString();
}
}
Expand Down

0 comments on commit 7cf684c

Please sign in to comment.