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,12 +296,9 @@ export default async function build( ...@@ -296,12 +296,9 @@ export default async function build(
) )
if (hasMiddleware) { if (hasMiddleware) {
console.warn( Log.warn(
chalk.bold.yellow(`Warning: `) +
chalk.yellow(
`using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware` `using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
) )
)
} }
if (hasPublicDir) { if (hasPublicDir) {
......
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,12 +594,9 @@ export default class Server { ...@@ -595,12 +594,9 @@ 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: `) +
chalk.yellow(
`using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware` `using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware`
) )
)
}) })
protected async runMiddleware(params: { protected async runMiddleware(params: {
...@@ -2300,12 +2296,9 @@ export default class Server { ...@@ -2300,12 +2296,9 @@ export default class Server {
} }
private customErrorNo404Warn = execOnce(() => { private customErrorNo404Warn = execOnce(() => {
console.warn( Log.warn(
chalk.bold.yellow(`Warning: `) +
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` `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`
) )
)
}) })
private async renderErrorToResponse( private async renderErrorToResponse(
......
...@@ -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