-
Notifications
You must be signed in to change notification settings - Fork 25
JSON based logger #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON based logger #642
Changes from 2 commits
3ed97fa
44d18a9
fdf2b26
a72f6a1
0a90acc
521ec45
3a8acc2
2dc4c18
a9da80c
067ab02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@graphql-hive/gateway': patch | ||
| --- | ||
|
|
||
| dependencies updates: | ||
|
|
||
| - Added dependency [`@graphql-hive/logger-json@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-hive/logger-json/v/workspace:^) (to `dependencies`) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| '@graphql-mesh/transport-http-callback': patch | ||
| '@graphql-mesh/plugin-opentelemetry': patch | ||
| '@graphql-mesh/fusion-runtime': patch | ||
| '@graphql-mesh/transport-ws': patch | ||
| '@graphql-hive/importer': patch | ||
| '@graphql-hive/gateway': patch | ||
| '@graphql-hive/gateway-runtime': patch | ||
| --- | ||
|
|
||
| New JSON-based logger |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,8 @@ | |
| import 'dotenv/config'; // inject dotenv options to process.env | ||
|
|
||
| import module from 'node:module'; | ||
| import { JSONLogger } from '@graphql-hive/gateway-runtime'; | ||
|
||
| import type { InitializeData } from '@graphql-hive/importer/hooks'; | ||
| import { DefaultLogger } from '@graphql-mesh/utils'; | ||
| import { enableModuleCachingIfPossible, handleNodeWarnings, run } from './cli'; | ||
|
|
||
| // @inject-version globalThis.__VERSION__ here | ||
|
|
@@ -20,7 +20,7 @@ module.register('@graphql-hive/importer/hooks', { | |
| enableModuleCachingIfPossible(); | ||
| handleNodeWarnings(); | ||
|
|
||
| const log = new DefaultLogger(); | ||
| const log = new JSONLogger(); | ||
|
||
|
|
||
| run({ log }).catch((err) => { | ||
| log.error(err); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| export const isDebug = ['1', 'y', 'yes', 't', 'true'].includes( | ||
| String(process.env['DEBUG']), | ||
| ); | ||
| export const isDebug = ['importer'].includes(String(process.env['DEBUG'])); | ||
|
|
||
| export function debug(msg: string) { | ||
| export function debug(message: string) { | ||
| if (isDebug) { | ||
| process.stderr.write(`[${new Date().toISOString()}] HOOKS ${msg}\n`); | ||
| process.stderr.write( | ||
| `${JSON.stringify({ | ||
| name: 'importer', | ||
| level: 'debug', | ||
| message, | ||
| })}\n`, | ||
| ); | ||
|
Comment on lines
+1
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Optional enhancement for debug condition and logging consistency.
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||||||||||||||||
| { | ||||||||||||||||||||
| "name": "@graphql-hive/logger-json", | ||||||||||||||||||||
| "version": "0.0.0", | ||||||||||||||||||||
| "type": "module", | ||||||||||||||||||||
ardatan marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+1
to
+4
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainMissing changeset file for the new package. According to the coding guidelines, a changeset file is required for new packages. Please create one using
Let me check if a changeset file exists: 🏁 Script executed: #!/bin/bash
# Look for changeset files
fd -e md . .changeset/Length of output: 1716 Missing changeset file for @graphql-hive/logger-json package |
||||||||||||||||||||
| "repository": { | ||||||||||||||||||||
| "type": "git", | ||||||||||||||||||||
| "url": "git+https://github.com/graphql-hive/gateway.git", | ||||||||||||||||||||
| "directory": "packages/logger-json" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "author": { | ||||||||||||||||||||
| "email": "[email protected]", | ||||||||||||||||||||
| "name": "The Guild", | ||||||||||||||||||||
| "url": "https://the-guild.dev" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "license": "MIT", | ||||||||||||||||||||
| "engines": { | ||||||||||||||||||||
| "node": ">=18.0.0" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "main": "./dist/index.js", | ||||||||||||||||||||
| "exports": { | ||||||||||||||||||||
| ".": { | ||||||||||||||||||||
| "require": { | ||||||||||||||||||||
| "types": "./dist/index.d.cts", | ||||||||||||||||||||
| "default": "./dist/index.cjs" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "import": { | ||||||||||||||||||||
| "types": "./dist/index.d.ts", | ||||||||||||||||||||
| "default": "./dist/index.js" | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "./package.json": "./package.json" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "types": "./dist/index.d.ts", | ||||||||||||||||||||
| "files": [ | ||||||||||||||||||||
| "dist" | ||||||||||||||||||||
| ], | ||||||||||||||||||||
| "scripts": { | ||||||||||||||||||||
| "build": "pkgroll --clean-dist", | ||||||||||||||||||||
| "prepack": "yarn build" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
|
Comment on lines
+37
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Add test script to package.json. Consider adding a test script to ensure the logger functionality is properly tested: "scripts": {
"build": "pkgroll --clean-dist",
- "prepack": "yarn build"
+ "prepack": "yarn build",
+ "test": "jest"
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
| "peerDependencies": { | ||||||||||||||||||||
| "graphql": "^15.9.0 || ^16.9.0" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "dependencies": { | ||||||||||||||||||||
| "@graphql-mesh/cross-helpers": "^0.4.9", | ||||||||||||||||||||
| "@graphql-mesh/types": "^0.103.6", | ||||||||||||||||||||
| "@graphql-mesh/utils": "^0.103.6", | ||||||||||||||||||||
| "tslib": "^2.8.1" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "devDependencies": { | ||||||||||||||||||||
| "graphql": "^16.9.0", | ||||||||||||||||||||
| "pkgroll": "2.8.2" | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "sideEffects": false | ||||||||||||||||||||
| } | ||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update this before merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!