From 97d9a13846654b8fa5b7520254f0f5ebc575305b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 2 Oct 2023 17:09:26 -0300 Subject: write: live-dev-server: default to quiet responses --- src/write/build-modes/live-dev-server.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/write/build-modes') diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index 3986de32..d4efd177 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -42,8 +42,8 @@ export function getCLIOptions() { }, }, - 'quiet-responses': { - help: `Disables outputting [200] and [404] responses in the server log`, + 'loud-responses': { + help: `Enables outputting [200] and [404] responses in the server log, which are suppressed by default`, type: 'flag', }, }; @@ -78,7 +78,7 @@ export async function go({ const host = cliOptions['host'] ?? defaultHost; const port = parseInt(cliOptions['port'] ?? defaultPort); - const quietResponses = cliOptions['quiet-responses'] ?? false; + const loudResponses = cliOptions['loud-responses'] ?? false; const contentDependenciesWatcher = await watchContentDependencies(); const {contentDependencies} = contentDependenciesWatcher; @@ -160,7 +160,7 @@ export async function go({ }); response.writeHead(200, contentTypeJSON); response.end(json); - if (!quietResponses) console.log(`${requestHead} [200] /data.json`); + if (loudResponses) console.log(`${requestHead} [200] /data.json`); } catch (error) { response.writeHead(500, contentTypeJSON); response.end(`Internal error serializing wiki JSON`); @@ -256,7 +256,7 @@ export async function go({ await pipeline( createReadStream(filePath), response); - if (!quietResponses) console.log(`${requestHead} [200] ${pathname}`); + if (loudResponses) console.log(`${requestHead} [200] ${pathname}`); } catch (error) { response.writeHead(500, contentTypePlain); response.end(`Failed during file-to-response pipeline`); @@ -274,7 +274,7 @@ export async function go({ if (!Object.hasOwn(urlToPageMap, pathnameKey)) { response.writeHead(404, contentTypePlain); response.end(`No page found for: ${pathnameKey}\n`); - if (!quietResponses) console.log(`${requestHead} [404] ${pathname}`); + if (loudResponses) console.log(`${requestHead} [404] ${pathname}`); return; } @@ -358,7 +358,7 @@ export async function go({ const {pageHTML} = html.resolve(topLevelResult); - if (!quietResponses) console.log(`${requestHead} [200] ${pathname}`); + if (loudResponses) console.log(`${requestHead} [200] ${pathname}`); response.writeHead(200, contentTypeHTML); response.end(pageHTML); } catch (error) { @@ -388,8 +388,11 @@ export async function go({ server.on('listening', () => { logInfo`${'All done!'} Listening at: ${address}`; logInfo`Press ^C here (control+C) to stop the server and exit.`; - if (quietResponses) { - logInfo`Suppressing [200] and [404] response logging.`; + if (loudResponses) { + logInfo`Printing [200] and [404] responses.` + } else { + logInfo`Suppressing [200] and [404] response logging.` + logInfo`(Pass --loud-responses to show these.)`; } }); -- cgit 1.3.0-6-gf8a5