From fba65b2ca7d8aa0436cdab979c63ae48686d9414 Mon Sep 17 00:00:00 2001 From: kongmoumou Date: Mon, 15 Jan 2024 22:12:59 +0800 Subject: [PATCH 1/3] fix(nuxt): control nitro log level with nuxt options --- packages/nuxt/src/core/nitro.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 8303c4fee7b1..28d23a6da905 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -11,7 +11,7 @@ import escapeRE from 'escape-string-regexp' import { defu } from 'defu' import fsExtra from 'fs-extra' import { dynamicEventHandler } from 'h3' -import type { Nuxt, RuntimeConfig } from 'nuxt/schema' +import type { Nuxt, NuxtOptions, RuntimeConfig } from 'nuxt/schema' // @ts-expect-error TODO: add legacy type support for subpath imports import { template as defaultSpaLoadingTemplate } from '@nuxt/ui-templates/templates/spa-loading-icon.mjs' import { version as nuxtVersion } from '../../package.json' @@ -19,6 +19,12 @@ import { distDir } from '../dirs' import { toArray } from '../utils' import { ImportProtectionPlugin } from './plugins/import-protection' +export const logLevelMapReverse: Record = { + silent: 0, + info: 3, + verbose: 3 +} + export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { // Resolve config const _nitroConfig = ((nuxt.options as any).nitro || {}) as NitroConfig @@ -218,7 +224,8 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { rollupConfig: { output: {}, plugins: [] - } + }, + logLevel: logLevelMapReverse[nuxt.options.logLevel], } satisfies NitroConfig) // Resolve user-provided paths From 0abfce1c12d2b1bae2f4a0f8ec77938913c4e3c4 Mon Sep 17 00:00:00 2001 From: kongmoumou Date: Mon, 15 Jan 2024 22:44:27 +0800 Subject: [PATCH 2/3] chore: remove export --- packages/nuxt/src/core/nitro.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 28d23a6da905..a596ec2ea5ce 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -19,7 +19,7 @@ import { distDir } from '../dirs' import { toArray } from '../utils' import { ImportProtectionPlugin } from './plugins/import-protection' -export const logLevelMapReverse: Record = { +const logLevelMapReverse: Record = { silent: 0, info: 3, verbose: 3 From f3cbb66eacffeaf250cc88ecfb44cde22f9dbb81 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 15 Jan 2024 17:14:59 +0000 Subject: [PATCH 3/3] chore: use satisfies --- packages/nuxt/src/core/nitro.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index a596ec2ea5ce..6c8632f502c9 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -19,11 +19,11 @@ import { distDir } from '../dirs' import { toArray } from '../utils' import { ImportProtectionPlugin } from './plugins/import-protection' -const logLevelMapReverse: Record = { +const logLevelMapReverse = { silent: 0, info: 3, verbose: 3 -} +} satisfies Record export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { // Resolve config