Skip to content

Commit

Permalink
style: Rename append{Escaped => Json}String.
Browse files Browse the repository at this point in the history
Change-Id: Ie77c964f211d5cfa89edaa21b3d458afcc4402c7
  • Loading branch information
benkard committed Jul 3, 2024
1 parent f555383 commit a33e7ff
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void json(StringBuilder b) {

if (file != null) {
b.append("\"file\":");
appendEscapedString(b, file);
appendJsonString(b, file);
commaNeeded = true;
}

Expand All @@ -90,7 +90,7 @@ void json(StringBuilder b) {
b.append(",");
}
b.append("\"line\":");
appendEscapedString(b, line);
appendJsonString(b, line);
commaNeeded = true;
}

Expand All @@ -99,7 +99,7 @@ void json(StringBuilder b) {
b.append(",");
}
b.append("\"function\":");
appendEscapedString(b, function);
appendJsonString(b, function);
}
}
}
Expand Down Expand Up @@ -130,25 +130,25 @@ void json(StringBuilder b) {

if (insertId != null) {
b.append("\"logging.googleapis.com/insertId\":");
appendEscapedString(b, insertId);
appendJsonString(b, insertId);
b.append(",");
}

if (trace != null) {
b.append("\"logging.googleapis.com/trace\":");
appendEscapedString(b, trace);
appendJsonString(b, trace);
b.append(",");
}

if (spanId != null) {
b.append("\"logging.googleapis.com/spanId\":");
appendEscapedString(b, spanId);
appendJsonString(b, spanId);
b.append(",");
}

if (nestedDiagnosticContext != null && !nestedDiagnosticContext.isEmpty()) {
b.append("\"nestedDiagnosticContext\":");
appendEscapedString(b, nestedDiagnosticContext);
appendJsonString(b, nestedDiagnosticContext);
b.append(",");
}

Expand All @@ -163,26 +163,26 @@ void json(StringBuilder b) {
first = false;
}

appendEscapedString(b, entry.getKey());
appendJsonString(b, entry.getKey());
b.append(":");
appendEscapedString(b, entry.getValue());
appendJsonString(b, entry.getValue());
}

b.append("},");
}

for (var entry : mappedDiagnosticContext.entrySet()) {
appendEscapedString(b, entry.getKey());
appendJsonString(b, entry.getKey());
b.append(":");
appendEscapedString(b, entry.getValue());
appendJsonString(b, entry.getValue());
b.append(",");
}

for (var parameter : parameters) {
var jsonObject = parameter.json().build();
jsonObject.forEach(
(key, value) -> {
appendEscapedString(b, key);
appendJsonString(b, key);
b.append(":");
appendJsonObject(b, value);
b.append(",");
Expand All @@ -191,7 +191,7 @@ void json(StringBuilder b) {

if (type != null) {
b.append("\"@type\":");
appendEscapedString(b, type);
appendJsonString(b, type);
b.append(",");
}

Expand All @@ -202,10 +202,10 @@ void json(StringBuilder b) {
}

b.append("\"message\":");
appendEscapedString(b, message);
appendJsonString(b, message);

b.append(",\"severity\":");
appendEscapedString(b, severity);
appendJsonString(b, severity);

b.append(",\"timestamp\":{");
timestamp.json(b);
Expand Down Expand Up @@ -236,15 +236,15 @@ private static void appendJsonObject(StringBuilder b, JsonValue value) {
} else {
first = false;
}
appendEscapedString(b, entry.getKey());
appendJsonString(b, entry.getKey());
b.append(":");
appendJsonObject(b, entry.getValue());
}
b.append("}");
break;

case STRING:
appendEscapedString(b, ((JsonString) value).getString());
appendJsonString(b, ((JsonString) value).getString());
break;

case NUMBER:
Expand All @@ -265,7 +265,7 @@ private static void appendJsonObject(StringBuilder b, JsonValue value) {
}
}

private static void appendEscapedString(StringBuilder b, String s) {
private static void appendJsonString(StringBuilder b, String s) {
b.append('"');

for (var i = 0; i < s.length(); i++) {
Expand Down

0 comments on commit a33e7ff

Please sign in to comment.