Unverified Commit 367a420d authored by Steven's avatar Steven Committed by GitHub

Use `Log.warn()` instead of `console.warn()` in next-server (#30240)

* Use Log.warn() instead of console.warn() in next-server

* Update test and update build warn as well
Co-authored-by: 's avatarjj@jjsweb.site <jj@jjsweb.site>
parent df613d39
...@@ -296,11 +296,8 @@ export default async function build( ...@@ -296,11 +296,8 @@ export default async function build(
) )
if (hasMiddleware) { if (hasMiddleware) {
console.warn( Log.warn(
chalk.bold.yellow(`Warning: `) + `using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
chalk.yellow(
`using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
)
) )
} }
......
import compression from 'next/dist/compiled/compression' import compression from 'next/dist/compiled/compression'
import fs from 'fs' import fs from 'fs'
import chalk from 'chalk'
import { IncomingMessage, ServerResponse } from 'http' import { IncomingMessage, ServerResponse } from 'http'
import Proxy from 'next/dist/compiled/http-proxy' import Proxy from 'next/dist/compiled/http-proxy'
import { join, relative, resolve, sep } from 'path' import { join, relative, resolve, sep } from 'path'
...@@ -595,11 +594,8 @@ export default class Server { ...@@ -595,11 +594,8 @@ export default class Server {
protected async ensureMiddleware(_pathname: string) {} protected async ensureMiddleware(_pathname: string) {}
private middlewareBetaWarning = execOnce(() => { private middlewareBetaWarning = execOnce(() => {
console.warn( Log.warn(
chalk.bold.yellow(`Warning: `) + `using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
chalk.yellow(
`using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
)
) )
}) })
...@@ -2300,11 +2296,8 @@ export default class Server { ...@@ -2300,11 +2296,8 @@ export default class Server {
} }
private customErrorNo404Warn = execOnce(() => { private customErrorNo404Warn = execOnce(() => {
console.warn( Log.warn(
chalk.bold.yellow(`Warning: `) + `You have added a custom /_error page without a custom /404 page. This prevents the 404 page from being auto statically optimized.\nSee here for info: https://nextjs.org/docs/messages/custom-error-no-custom-404`
chalk.yellow(
`You have added a custom /_error page without a custom /404 page. This prevents the 404 page from being auto statically optimized.\nSee here for info: https://nextjs.org/docs/messages/custom-error-no-custom-404`
)
) )
}) })
......
...@@ -17,8 +17,7 @@ jest.setTimeout(1000 * 60 * 2) ...@@ -17,8 +17,7 @@ jest.setTimeout(1000 * 60 * 2)
const context = {} const context = {}
context.appDir = join(__dirname, '../') context.appDir = join(__dirname, '../')
const middlewareWarning = const middlewareWarning = 'using beta Middleware (not covered by semver)'
'Warning: using beta Middleware (not covered by semver)'
describe('Middleware base tests', () => { describe('Middleware base tests', () => {
describe('dev mode', () => { describe('dev mode', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment