fix(vue-renderer): safe format ssr logs (#5764)

This commit is contained in:
Pooya Parsa 2019-05-19 23:19:24 +04:30 committed by GitHub
parent dbb9f03959
commit 38fc721f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import path from 'path' import path from 'path'
import crypto from 'crypto' import crypto from 'crypto'
import { format } from 'util'
import fs from 'fs-extra' import fs from 'fs-extra'
import consola from 'consola' import consola from 'consola'
import devalue from '@nuxt/devalue' import devalue from '@nuxt/devalue'
@ -42,10 +43,10 @@ export default class SSRRenderer extends BaseRenderer {
const logs = [] const logs = []
const devReporter = { const devReporter = {
log(logObj) { log(logObj) {
if (logObj.args[0] instanceof Error) { logs.push({
logObj.args[0] = logObj.args[0].stack ...logObj,
} args: logObj.args.map(format)
logs.push(logObj) })
} }
} }
consola.addReporter(devReporter) consola.addReporter(devReporter)