From 6668380308575ba7a09039e6e6c5a63631c5420a Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Wed, 13 Nov 2024 12:23:13 +0000 Subject: [PATCH 1/5] Output provider logs as JSON --- packages/common/src/logger.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/common/src/logger.ts b/packages/common/src/logger.ts index 43acdcdace..53def80450 100644 --- a/packages/common/src/logger.ts +++ b/packages/common/src/logger.ts @@ -11,7 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import { LogLevels as ConsolaLogLevels, createConsola } from "consola/browser"; +import consola, { + LogLevels as ConsolaLogLevels, + createConsola, +} from "consola/browser"; import { enum as zEnum, type infer as zInfer } from "zod"; import { ProsopoEnvError } from "./error.js"; @@ -47,8 +50,18 @@ export function getLoggerDefault(): Logger { return defaultLogger; } +// biome-ignore lint/suspicious/noExplicitAny: +const JSONReporter = (message: any) => { + process.stderr.write(`${JSON.stringify(message)}\n`); +}; + const getLoggerAdapterConsola = (logLevel: LogLevel, scope: string): Logger => { const logger = createConsola({ + reporters: [ + { + log: JSONReporter, + }, + ], formatOptions: { colors: true, date: true }, }).withTag(scope); let currentLevel = logLevel; From 47b718bc22b3bcbe72312ee060e508f83164a719 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Wed, 13 Nov 2024 12:28:38 +0000 Subject: [PATCH 2/5] Add reason for any --- packages/common/src/logger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/logger.ts b/packages/common/src/logger.ts index 53def80450..d8dbcccf0e 100644 --- a/packages/common/src/logger.ts +++ b/packages/common/src/logger.ts @@ -50,7 +50,7 @@ export function getLoggerDefault(): Logger { return defaultLogger; } -// biome-ignore lint/suspicious/noExplicitAny: +// biome-ignore lint/suspicious/noExplicitAny: we should be able to log anything we want, plus we can't control what external libraries log const JSONReporter = (message: any) => { process.stderr.write(`${JSON.stringify(message)}\n`); }; From 5cbfc68effaf4a2d5e4fc3ab01dc13647116223d Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Wed, 13 Nov 2024 12:32:27 +0000 Subject: [PATCH 3/5] Fix grep test --- .github/workflows/provider_image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index c13ef0fe80..35c40cce3c 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -5,7 +5,7 @@ name: provider_image on: pull_request: branches: [main, dev, staging, release/*] - types: + types: - opened # when a PR is opened - synchronize # when a PR is pushed to - reopened # when a PR is reopened @@ -151,7 +151,7 @@ jobs: sleep 20s docker logs "$CONTAINER" >& provider.log cat provider.log - grep -oE "Version: \".*\"" provider.log || (cat provider.log && exit 1) + grep -oE "Version: \\\\\".*\\\\\"" provider.log || (cat provider.log && exit 1) - name: Build the provider-mock package id: build_provider_mock_package From 6d1c7febcc45a1315ff97812e450dabf7bee2c41 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Wed, 13 Nov 2024 12:49:04 +0000 Subject: [PATCH 4/5] Stop logging the config as its being sent to OO --- packages/cli/src/cli.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 31f4ae9cc8..0f83fcb2e9 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -32,8 +32,6 @@ async function main() { unsolved: { count: 0 }, }); - log.info(config); - if (config.devOnlyWatchEvents) { log.warn( ` From 2d71d2106f649767141d4773e46c8117c1d778f1 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Wed, 13 Nov 2024 12:49:16 +0000 Subject: [PATCH 5/5] Change where we look for the Version string --- packages/cli/src/tests/bundle/bundle.unit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/tests/bundle/bundle.unit.test.ts b/packages/cli/src/tests/bundle/bundle.unit.test.ts index 34a967adb1..79693fca48 100644 --- a/packages/cli/src/tests/bundle/bundle.unit.test.ts +++ b/packages/cli/src/tests/bundle/bundle.unit.test.ts @@ -29,6 +29,6 @@ describe("provider bundle", () => { const { stdout: runOut, stderr: runErr } = await execPromise( `cd ${rootDir} && node dist/bundle/provider.cli.bundle.js version`, ); - assert(runOut.includes("Version:")); + assert(runErr.includes("Version:")); }, 120000); });