Add colors to debug logging

This commit is contained in:
Lauren Tan
2023-01-25 16:15:12 -05:00
parent e6b4988b1e
commit 840bb6fec2
3 changed files with 16 additions and 23 deletions
+1 -1
View File
@@ -29,6 +29,7 @@
"@babel/generator": "7.2.0",
"@babel/plugin-syntax-jsx": "^7.18.6",
"@babel/types": "^7.19.0",
"chalk": "4",
"invariant": "^2.2.4",
"prettier": "2.7.1",
"pretty-format": "^24"
@@ -50,7 +51,6 @@
"@types/jest": "^29.0.3",
"@types/node": "^18.7.18",
"babel-jest": "^29.0.3",
"chalk": "^3.0.0",
"concurrently": "^7.4.0",
"eslint": "^8.25.0",
"glob": "^7.1.6",
+7 -6
View File
@@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import chalk from "chalk";
import { HIR, HIRFunction, ReactiveFunction } from "../HIR/HIR";
import { printFunction, printHIR } from "../HIR/PrintHIR";
import { printReactiveFunction } from "../ReactiveScopes";
@@ -22,9 +23,9 @@ export function logHIR(step: string, ir: HIR): void {
const printed = printHIR(ir);
if (printed !== lastLogged) {
lastLogged = printed;
process.stdout.write(`${step}:\n${printed}\n\n`);
process.stdout.write(`${chalk.green(step)}:\n${printed}\n\n`);
} else {
process.stdout.write(`${step}: (no change)\n\n`);
process.stdout.write(`${chalk.blue(step)}: (no change)\n\n`);
}
}
}
@@ -34,9 +35,9 @@ export function logHIRFunction(step: string, fn: HIRFunction): void {
const printed = printFunction(fn);
if (printed !== lastLogged) {
lastLogged = printed;
process.stdout.write(`${step}:\n${printed}\n\n`);
process.stdout.write(`${chalk.green(step)}:\n${printed}\n\n`);
} else {
process.stdout.write(`${step}: (no change)\n\n`);
process.stdout.write(`${chalk.blue(step)}: (no change)\n\n`);
}
}
}
@@ -46,9 +47,9 @@ export function logReactiveFunction(step: string, fn: ReactiveFunction): void {
const printed = printReactiveFunction(fn);
if (printed !== lastLogged) {
lastLogged = printed;
process.stdout.write(`${step}:\n${printed}\n\n`);
process.stdout.write(`${chalk.green(step)}:\n${printed}\n\n`);
} else {
process.stdout.write(`${step}: (no change)\n\n`);
process.stdout.write(`${chalk.blue(step)}: (no change)\n\n`);
}
}
}
+8 -16
View File
@@ -1455,6 +1455,14 @@ caniuse-lite@^1.0.30001400:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001410.tgz#b5a86366fbbf439d75dd3db1d21137a73e829f44"
integrity sha512-QoblBnuE+rG0lc3Ur9ltP5q47lbguipa/ncNMyyGuqPk44FxbScWAeEO+k5fSQ8WekdAK4mWqNs1rADDAiN5xQ==
chalk@4, chalk@^4.0.0, chalk@^4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chalk@^2.0.0:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
@@ -1464,22 +1472,6 @@ chalk@^2.0.0:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
chalk@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chalk@^4.0.0, chalk@^4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
char-regex@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"