Skip to content

Commit 237ba5c

Browse files
authored
Fix debug output (#857)
Correctly handle compress and remove body from response log
1 parent cde4123 commit 237ba5c

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

.generator/src/generator/templates/http/isomorphic-fetch.j2

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
9090
const body = request.getBody()
9191
? JSON.stringify(request.getBody(), null, 2).replace(/\n/g, "\n\t")
9292
: "";
93-
const compress = request.getHttpConfig().compress || true;
93+
const compress = request.getHttpConfig().compress ?? true;
9494

9595
console.debug(
9696
"\nrequest: {\n",
@@ -108,15 +108,10 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
108108
/\n/g,
109109
"\n\t"
110110
);
111-
const body = response.body
112-
? JSON.stringify(response.body, null, 2).replace(/\n/g, "\n\t")
113-
: "";
114-
115111
console.debug(
116112
"response: {\n",
117113
`\tstatus: ${httpStatusCode}\n`,
118-
`\theaders: ${headers}\n`,
119-
`\tbody: ${body}\n}\n`
114+
`\theaders: ${headers}\n`
120115
);
121116
}
122117
}

packages/datadog-api-client-common/http/isomorphic-fetch.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
9595
const body = request.getBody()
9696
? JSON.stringify(request.getBody(), null, 2).replace(/\n/g, "\n\t")
9797
: "";
98-
const compress = request.getHttpConfig().compress || true;
98+
const compress = request.getHttpConfig().compress ?? true;
9999

100100
console.debug(
101101
"\nrequest: {\n",
@@ -113,15 +113,10 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
113113
/\n/g,
114114
"\n\t"
115115
);
116-
const body = response.body
117-
? JSON.stringify(response.body, null, 2).replace(/\n/g, "\n\t")
118-
: "";
119-
120116
console.debug(
121117
"response: {\n",
122118
`\tstatus: ${httpStatusCode}\n`,
123-
`\theaders: ${headers}\n`,
124-
`\tbody: ${body}\n}\n`
119+
`\theaders: ${headers}\n`
125120
);
126121
}
127122
}

0 commit comments

Comments
 (0)