@jsenv/server 12.5.5 → 12.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/startServer.js +7 -4
package/package.json
CHANGED
package/src/startServer.js
CHANGED
|
@@ -291,9 +291,12 @@ export const startServer = async ({
|
|
|
291
291
|
// keep buffering until root request write logs for everyone
|
|
292
292
|
return
|
|
293
293
|
}
|
|
294
|
+
const prefixLines = (string, prefix) => {
|
|
295
|
+
return string.replace(/^(?!\s*$)/gm, prefix)
|
|
296
|
+
}
|
|
294
297
|
const writeLog = ({ type, value }, depth) => {
|
|
295
298
|
if (depth > 0) {
|
|
296
|
-
value = value
|
|
299
|
+
value = prefixLines(value, " ".repeat(depth))
|
|
297
300
|
}
|
|
298
301
|
logger[type](value)
|
|
299
302
|
}
|
|
@@ -303,7 +306,7 @@ export const startServer = async ({
|
|
|
303
306
|
const middleLogs = requestNode.logs
|
|
304
307
|
writeLog(firstLog, depth)
|
|
305
308
|
middleLogs.forEach((log) => {
|
|
306
|
-
writeLog(log, depth
|
|
309
|
+
writeLog(log, depth)
|
|
307
310
|
})
|
|
308
311
|
requestNode.children.forEach((child) => {
|
|
309
312
|
visitRequestNodeToLog(child, depth + 1)
|
|
@@ -672,11 +675,11 @@ export const startServer = async ({
|
|
|
672
675
|
})
|
|
673
676
|
onRequestHandled(requestNode)
|
|
674
677
|
},
|
|
675
|
-
onHeadersSent: ({ status, statusText
|
|
678
|
+
onHeadersSent: ({ status, statusText }) => {
|
|
676
679
|
addRequestLog(requestNode, {
|
|
677
680
|
type: "info",
|
|
678
681
|
value: `${colorizeResponseStatus(status)} ${
|
|
679
|
-
statusMessage || statusText
|
|
682
|
+
responseProperties.statusMessage || statusText
|
|
680
683
|
}`,
|
|
681
684
|
})
|
|
682
685
|
},
|