Skip to content

Commit 0a90acc

Browse files
committed
Lets go
1 parent a72f6a1 commit 0a90acc

File tree

8 files changed

+41
-45
lines changed

8 files changed

+41
-45
lines changed

packages/fusion-runtime/tests/polling.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import { DisposableSymbols } from '@whatwg-node/disposablestack';
1717
import { ExecutionResult, GraphQLSchema, parse } from 'graphql';
1818
import { createSchema } from 'graphql-yoga';
1919
import { describe, expect, it, vi } from 'vitest';
20-
import { UnifiedGraphManager } from '../src/unifiedGraphManager';
2120
import { getDefaultLogger } from '../../runtime/src/getDefaultLogger';
21+
import { UnifiedGraphManager } from '../src/unifiedGraphManager';
2222

2323
describe('Polling', () => {
2424
const advanceTimersByTimeAsync = vi.advanceTimersByTimeAsync || setTimeout;

packages/gateway/src/bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'dotenv/config'; // inject dotenv options to process.env
33

44
import module from 'node:module';
55
import type { InitializeData } from '@graphql-hive/importer/hooks';
6-
import { enableModuleCachingIfPossible, handleNodeWarnings, run } from './cli';
76
import { getDefaultLogger } from '../../runtime/src/getDefaultLogger';
7+
import { enableModuleCachingIfPossible, handleNodeWarnings, run } from './cli';
88

99
// @inject-version globalThis.__VERSION__ here
1010

packages/gateway/src/cli.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
type GatewayConfigSupergraph,
1515
type GatewayGraphOSReportingOptions,
1616
type GatewayHiveReportingOptions,
17-
JSONLogger,
1817
} from '@graphql-hive/gateway-runtime';
1918
import type UpstashRedisCache from '@graphql-mesh/cache-upstash-redis';
2019
import type { JWTAuthPluginOptions } from '@graphql-mesh/plugin-jwt-auth';
@@ -28,11 +27,11 @@ import type {
2827
YamlConfig,
2928
} from '@graphql-mesh/types';
3029
import parseDuration from 'parse-duration';
30+
import { getDefaultLogger } from '../../runtime/src/getDefaultLogger';
3131
import { addCommands } from './commands/index';
3232
import { createDefaultConfigPaths } from './config';
3333
import { getMaxConcurrency } from './getMaxConcurrency';
3434
import type { ServerConfig } from './servers/types';
35-
import { getDefaultLogger } from '../../runtime/src/getDefaultLogger';
3635

3736
export type GatewayCLIConfig = (
3837
| GatewayCLISupergraphConfig

packages/gateway/src/commands/handleFork.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ export function handleFork(log: Logger, config: { fork?: number }): boolean {
1313
const workerLogger = log.child({ worker: worker.id });
1414
worker.once('exit', (code, signal) => {
1515
if (expectedToExit) {
16-
workerLogger.debug(
17-
'exited',
18-
{
19-
code,
20-
signal,
21-
},
22-
);
16+
workerLogger.debug('exited', {
17+
code,
18+
signal,
19+
});
2320
} else {
2421
workerLogger.error(
2522
'exited unexpectedly. A restart is recommended to ensure the stability of the service',

packages/runtime/src/createGatewayRuntime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {
7878
} from 'graphql-yoga';
7979
import type { GraphiQLOptions, PromiseOrValue } from 'graphql-yoga';
8080
import { createGraphOSFetcher } from './fetchers/graphos';
81+
import { getDefaultLogger } from './getDefaultLogger';
8182
import { getProxyExecutor } from './getProxyExecutor';
8283
import { getReportingPlugin } from './getReportingPlugin';
8384
import {
@@ -110,7 +111,6 @@ import {
110111
defaultQueryText,
111112
getExecuteFnFromExecutor,
112113
} from './utils';
113-
import { getDefaultLogger } from './getDefaultLogger';
114114

115115
// TODO: this type export is not properly accessible from graphql-yoga
116116
// "graphql-yoga/typings/plugins/use-graphiql.js" is an illegal path
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1+
// eslint-disable-next-line import/no-nodejs-modules
2+
import { Console } from 'node:console';
13
import { JSONLogger } from '@graphql-hive/logger-json';
24
import { process } from '@graphql-mesh/cross-helpers';
35
import { LogLevel } from '@graphql-mesh/utils';
4-
// eslint-disable-next-line import/no-nodejs-modules
5-
import { Console } from 'node:console';
66
import pinoPretty from 'pino-pretty';
77

8-
export function getDefaultLogger(opts?: { name?: string; level?: LogLevel; }) {
9-
const logFormat = process.env['LOG_FORMAT'] || (globalThis as any).LOG_FORMAT;
10-
if (logFormat) {
11-
if (logFormat.toLowerCase() === 'json') {
12-
return new JSONLogger(opts);
13-
} else if (logFormat.toLowerCase() === 'pretty') {
14-
return createPrettyLogger(opts);
15-
}
16-
}
17-
const nodeEnv = process.env['NODE_ENV'] || (globalThis as any).NODE_ENV;
18-
if (nodeEnv === 'production') {
19-
return new JSONLogger(opts);
8+
export function getDefaultLogger(opts?: { name?: string; level?: LogLevel }) {
9+
const logFormat = process.env['LOG_FORMAT'] || (globalThis as any).LOG_FORMAT;
10+
if (logFormat) {
11+
if (logFormat.toLowerCase() === 'json') {
12+
return new JSONLogger(opts);
13+
} else if (logFormat.toLowerCase() === 'pretty') {
14+
return createPrettyLogger(opts);
2015
}
21-
return createPrettyLogger(opts);
16+
}
17+
const nodeEnv = process.env['NODE_ENV'] || (globalThis as any).NODE_ENV;
18+
if (nodeEnv === 'production') {
19+
return new JSONLogger(opts);
20+
}
21+
return createPrettyLogger(opts);
2222
}
2323

24-
function createPrettyLogger(opts?: { name?: string; level?: LogLevel; }) {
25-
const stdOut = pinoPretty({
26-
levelFirst: true,
27-
colorize: true,
28-
destination: process.stdout,
29-
});
30-
const stdErr = pinoPretty({
31-
levelFirst: true,
32-
colorize: true,
33-
destination: process.stdout,
34-
});
35-
return new JSONLogger({
36-
...opts,
37-
console: new Console(stdOut, stdErr)
38-
});
39-
}
24+
function createPrettyLogger(opts?: { name?: string; level?: LogLevel }) {
25+
const stdOut = pinoPretty({
26+
levelFirst: true,
27+
colorize: true,
28+
destination: process.stdout,
29+
});
30+
const stdErr = pinoPretty({
31+
levelFirst: true,
32+
colorize: true,
33+
destination: process.stdout,
34+
});
35+
return new JSONLogger({
36+
...opts,
37+
console: new Console(stdOut, stdErr),
38+
});
39+
}

packages/runtime/src/plugins/useFetchDebug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function useFetchDebug<TContext extends Record<string, any>>(opts: {
1414
const fetchId = fetchAPI.crypto.randomUUID();
1515
const loggerMeta: Record<string, string> = {
1616
fetchId,
17-
}
17+
};
1818
if (requestId) {
1919
loggerMeta['requestId'] = requestId;
2020
}

packages/runtime/src/plugins/useSubgraphExecuteDebug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function useSubgraphExecuteDebug<
1515
const subgraphExecuteId = fetchAPI.crypto.randomUUID();
1616
const loggerMeta: Record<string, string> = {
1717
subgraphExecuteId,
18-
}
18+
};
1919
if (requestId) {
2020
loggerMeta['requestId'] = requestId;
2121
}

0 commit comments

Comments
 (0)