mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-16 19:04:48 +00:00
15 lines
595 B
TypeScript
15 lines
595 B
TypeScript
/* eslint-disable no-console */
|
|
import { defineNuxtPlugin } from '#app'
|
|
|
|
export default defineNuxtPlugin(({ app }) => {
|
|
// Only activate in development
|
|
const logs = app.$nuxt.payload.logs || []
|
|
if (logs.length > 0) {
|
|
const ssrLogStyle = 'background: #003C3C;border-radius: 0.5em;color: white;font-weight: bold;padding: 2px 0.5em;'
|
|
console.groupCollapsed && console.groupCollapsed('%cNuxt Server Logs', ssrLogStyle)
|
|
logs.forEach(logObj => (console[logObj.type] || console.log)(...logObj.args))
|
|
delete app.$nuxt.payload.logs
|
|
console.groupEnd && console.groupEnd()
|
|
}
|
|
})
|