feat: improve browser logs (#5810)

This commit is contained in:
Pooya Parsa 2019-05-27 13:02:53 +04:30 committed by Xin Du (Clark)
parent 1f74362d38
commit 09620d58a9

View File

@ -20,6 +20,8 @@ import { createApp, NuxtError } from './index.js'
import NuxtLink from './components/nuxt-link.<%= router.prefetchLinks ? "client" : "server" %>.js' // should be included after ./index.js import NuxtLink from './components/nuxt-link.<%= router.prefetchLinks ? "client" : "server" %>.js' // should be included after ./index.js
<% if (isDev) { %>import consola from 'consola'<% } %> <% if (isDev) { %>import consola from 'consola'<% } %>
<% if (isDev) { %>consola.wrapConsole()<% } %>
// Component: <NuxtLink> // Component: <NuxtLink>
Vue.component(NuxtLink.name, NuxtLink) Vue.component(NuxtLink.name, NuxtLink)
Vue.component('NLink', NuxtLink) Vue.component('NLink', NuxtLink)
@ -40,9 +42,8 @@ Object.assign(Vue.config, <%= serialize(vue.config) %>)<%= isTest ? '// eslint-d
<% if (nuxtOptions.render.ssrLog) { %> <% if (nuxtOptions.render.ssrLog) { %>
const logs = NUXT.logs || [] const logs = NUXT.logs || []
if (logs.length > 0) { if (logs.length > 0) {
console.group<%= nuxtOptions.render.ssrLog === 'collapsed' ? 'Collapsed' : '' %>("%c🚀 Nuxt.js SSR Logs", 'font-size: 110%') console.group<%= nuxtOptions.render.ssrLog === 'collapsed' ? 'Collapsed' : '' %>("%c🚀 Nuxt SSR Logs", 'font-size: 110%')
const logger = consola.withScope('nuxt:ssr') logs.forEach(logObj => consola[logObj.type](logObj))
logs.forEach(logObj => logger[logObj.type](logObj))
delete NUXT.logs delete NUXT.logs
console.groupEnd() console.groupEnd()
} }