Unverified Commit b82e2cde authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Fix missing new line for certain logs (#54442)

When logging are sending from worker they're missing new line, that
could be directly added after to spinner

#### After

![image](https://github.com/vercel/next.js/assets/4800338/c4494ff8-0335-49e3-8cce-2f9dc1fe7975)

#### Before

![image](https://github.com/vercel/next.js/assets/4800338/bcf3e27d-de39-4e27-ac57-09c922c09ecc)
parent 483ebc25
...@@ -8,40 +8,66 @@ export const prefixes = { ...@@ -8,40 +8,66 @@ export const prefixes = {
info: '- ' + chalk.cyan('info'), info: '- ' + chalk.cyan('info'),
event: '- ' + chalk.magenta('event'), event: '- ' + chalk.magenta('event'),
trace: '- ' + chalk.magenta('trace'), trace: '- ' + chalk.magenta('trace'),
} as const
const LOGGING_METHOD = {
log: 'log',
warn: 'warn',
error: 'error',
} as const
function prefixedLog(prefixType: keyof typeof prefixes, ...message: any[]) {
if ((message[0] === '' || message[0] === undefined) && message.length === 1) {
message.shift()
}
const consoleMethod: keyof typeof LOGGING_METHOD =
prefixType in LOGGING_METHOD
? LOGGING_METHOD[prefixType as keyof typeof LOGGING_METHOD]
: 'log'
const prefix = prefixes[prefixType]
// If there's no message, don't print the prefix but a new line
if (message.length === 0) {
console[consoleMethod]('')
} else {
console[consoleMethod](prefix, ...message)
}
} }
export function wait(...message: any[]) { export function wait(...message: any[]) {
console.log(prefixes.wait, ...message) prefixedLog('wait', ...message)
} }
export function error(...message: any[]) { export function error(...message: any[]) {
console.error(prefixes.error, ...message) prefixedLog('error', ...message)
} }
export function warn(...message: any[]) { export function warn(...message: any[]) {
console.warn(prefixes.warn, ...message) prefixedLog('warn', ...message)
} }
export function ready(...message: any[]) { export function ready(...message: any[]) {
console.log(prefixes.ready, ...message) prefixedLog('ready', ...message)
} }
export function info(...message: any[]) { export function info(...message: any[]) {
console.log(prefixes.info, ...message) prefixedLog('info', ...message)
} }
export function event(...message: any[]) { export function event(...message: any[]) {
console.log(prefixes.event, ...message) prefixedLog('event', ...message)
} }
export function trace(...message: any[]) { export function trace(...message: any[]) {
console.log(prefixes.trace, ...message) prefixedLog('trace', ...message)
} }
const warnOnceMessages = new Set() const warnOnceMessages = new Set()
export function warnOnce(...message: any[]) { export function warnOnce(...message: any[]) {
if (!warnOnceMessages.has(message[0])) { if (!warnOnceMessages.has(message[0])) {
warnOnceMessages.add(message.join(' ')) warnOnceMessages.add(message.join(' '))
warn(...message) warn(...message)
} }
} }
...@@ -210,6 +210,7 @@ async function lint( ...@@ -210,6 +210,7 @@ async function lint(
eslint = new ESLint(options) eslint = new ESLint(options)
} }
} else { } else {
Log.warn('')
Log.warn( Log.warn(
'The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config' 'The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config'
) )
......
...@@ -32,8 +32,9 @@ export function getSocialImageFallbackMetadataBase( ...@@ -32,8 +32,9 @@ export function getSocialImageFallbackMetadataBase(
} }
if (isMetadataBaseMissing) { if (isMetadataBaseMissing) {
Log.warnOnce('')
Log.warnOnce( Log.warnOnce(
`\nmetadata.metadataBase is not set for resolving social open graph or twitter images, using "${fallbackMetadata.origin}". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase` `metadata.metadataBase is not set for resolving social open graph or twitter images, using "${fallbackMetadata.origin}". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase`
) )
} }
......
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