2021-08-11 20:28:38 +00:00
|
|
|
import { defineNuxtPlugin } from '#app'
|
2021-01-18 12:46:19 +00:00
|
|
|
|
2021-10-18 18:31:37 +00:00
|
|
|
export default defineNuxtPlugin((nuxtApp) => {
|
2021-01-18 12:46:19 +00:00
|
|
|
// Only activate in development
|
2021-10-18 18:31:37 +00:00
|
|
|
const logs = nuxtApp.payload.logs || []
|
2021-01-18 12:46:19 +00:00
|
|
|
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))
|
2021-10-18 18:31:37 +00:00
|
|
|
delete nuxtApp.payload.logs
|
2021-01-18 12:46:19 +00:00
|
|
|
console.groupEnd && console.groupEnd()
|
|
|
|
}
|
2021-06-18 17:16:51 +00:00
|
|
|
})
|