Skip to content

Commit 8c1a027

Browse files
committed
changeset
1 parent db3abca commit 8c1a027

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

.changeset/odd-mammals-admire.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
'@graphql-hive/core': minor
3+
'@graphql-hive/apollo': minor
4+
'@graphql-hive/cli': minor
5+
'@graphql-hive/envelop': minor
6+
---
7+
8+
Introduce debug log level. HTTP retry log pollute the error log. The retries are now logged to the debug level.
9+
In order to see debug logs set the `debug` option to true.
10+
11+
```ts
12+
const hive = createHive({
13+
debug: true,
14+
})
15+
```
16+
17+
If you are using a custom logger, make sure to provide a `debug` logging method implementation.
18+
19+
```ts
20+
const hive = createHive({
21+
debug: true,
22+
agent: {
23+
logger: {
24+
info() {},
25+
error() {},
26+
debug() {}
27+
}
28+
}
29+
})
30+
```

packages/libraries/cli/src/base-command.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,15 @@ export default abstract class BaseCommand<T extends typeof Command> extends Comm
221221
}
222222
},
223223
error: (...args) => {
224-
// Allow retrying requests without noise
225224
if (isDebug) {
226225
this.logWarning(...args);
227226
}
228227
},
228+
debug: (...args) => {
229+
if (isDebug) {
230+
this.logInfo(...args);
231+
}
232+
},
229233
},
230234
headers: requestHeaders,
231235
timeout: args.timeout,

packages/libraries/core/src/client/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { createPersistedDocuments } from './persisted-documents.js';
1010
import { createReporting } from './reporting.js';
1111
import type { HiveClient, HiveInternalPluginOptions, HivePluginOptions } from './types.js';
1212
import { createUsage } from './usage.js';
13-
import { createHiveLogger, isLegacyAccessToken, logIf } from './utils.js';
13+
import { createHiveLogger, isLegacyAccessToken } from './utils.js';
1414

1515
export function createHive(options: HivePluginOptions): HiveClient {
1616
const logger = createHiveLogger(options?.agent?.logger ?? console, '[hive]', options.debug);

packages/libraries/core/src/client/http-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export async function makeFetchCall(
127127
}).catch((error: unknown) => {
128128
const logErrorMessage = () =>
129129
logger?.debug?.(
130-
`${config.method} ${endpoint} (x-request-id=${requestId}) failed ${getDuration()}. ` +
130+
`${config.method} ${endpoint} (x-request-id=${requestId}) failed ${getDuration()}.` +
131131
getErrorMessage(error),
132132
);
133133

0 commit comments

Comments
 (0)