diff --git a/boxes/boxes/react/package.json b/boxes/boxes/react/package.json index 863d7cf3eac..8e574163eb5 100644 --- a/boxes/boxes/react/package.json +++ b/boxes/boxes/react/package.json @@ -76,7 +76,6 @@ "ts-jest": "^29.1.0", "ts-loader": "^9.4.4", "ts-node": "^10.9.1", - "tty-browserify": "^0.0.1", "typescript": "^5.0.4", "util": "^0.12.5", "webpack": "^5.88.2", diff --git a/boxes/boxes/react/webpack.config.js b/boxes/boxes/react/webpack.config.js index d5e6fc11e01..4db17529911 100644 --- a/boxes/boxes/react/webpack.config.js +++ b/boxes/boxes/react/webpack.config.js @@ -48,7 +48,6 @@ export default (_, argv) => ({ util: require.resolve('util/'), stream: require.resolve('stream-browserify'), string_decoder: require.resolve('string_decoder/'), - tty: require.resolve('tty-browserify'), }, }, devServer: { diff --git a/boxes/boxes/vanilla/package.json b/boxes/boxes/vanilla/package.json index 0921135a760..045d0e976fa 100644 --- a/boxes/boxes/vanilla/package.json +++ b/boxes/boxes/vanilla/package.json @@ -28,7 +28,6 @@ "html-webpack-plugin": "^5.6.0", "stream-browserify": "^3.0.0", "ts-loader": "^9.5.1", - "tty-browserify": "^0.0.1", "typescript": "^5.0.4", "util": "^0.12.5", "webpack": "^5.90.1", diff --git a/boxes/boxes/vanilla/webpack.config.js b/boxes/boxes/vanilla/webpack.config.js index aa9f974b3a2..6fe89595fe0 100644 --- a/boxes/boxes/vanilla/webpack.config.js +++ b/boxes/boxes/vanilla/webpack.config.js @@ -44,7 +44,6 @@ export default (_, argv) => ({ util: require.resolve('util/'), stream: require.resolve('stream-browserify'), string_decoder: require.resolve('string_decoder/'), - tty: require.resolve('tty-browserify'), }, }, devServer: { diff --git a/boxes/contract-only/package.json b/boxes/contract-only/package.json index f262a39f6fc..f68de951d8e 100644 --- a/boxes/contract-only/package.json +++ b/boxes/contract-only/package.json @@ -43,7 +43,6 @@ "jest": "^29.6.4", "stream-browserify": "^3.0.0", "ts-loader": "^9.5.1", - "tty-browserify": "^0.0.1", "typescript": "^5.0.4", "util": "^0.12.5", "webpack": "^5.90.1", diff --git a/boxes/yarn.lock b/boxes/yarn.lock index 47091d6cb8c..526dda9a34f 100644 --- a/boxes/yarn.lock +++ b/boxes/yarn.lock @@ -104,7 +104,6 @@ __metadata: ts-jest: "npm:^29.1.0" ts-loader: "npm:^9.4.4" ts-node: "npm:^10.9.1" - tty-browserify: "npm:^0.0.1" typescript: "npm:^5.0.4" util: "npm:^0.12.5" webpack: "npm:^5.88.2" @@ -133,7 +132,6 @@ __metadata: html-webpack-plugin: "npm:^5.6.0" stream-browserify: "npm:^3.0.0" ts-loader: "npm:^9.5.1" - tty-browserify: "npm:^0.0.1" typescript: "npm:^5.0.4" util: "npm:^0.12.5" webpack: "npm:^5.90.1" @@ -8957,13 +8955,6 @@ __metadata: languageName: node linkType: hard -"tty-browserify@npm:^0.0.1": - version: 0.0.1 - resolution: "tty-browserify@npm:0.0.1" - checksum: 5e34883388eb5f556234dae75b08e069b9e62de12bd6d87687f7817f5569430a6dfef550b51dbc961715ae0cd0eb5a059e6e3fc34dc127ea164aa0f9b5bb033d - languageName: node - linkType: hard - "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0" diff --git a/docker-compose.yml b/docker-compose.yml index 952fd382939..cc5bec7a7ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: # need to run bb for proofs and bb is only built for x86 platform: linux/amd64 environment: - LOG_LEVEL: info - DEBUG: aztec:* + LOG_LEVEL: ${LOG_LEVEL:-info} + DEBUG: ${DEBUG:-aztec:*,-json-rpc:*,-aztec:circuits:artifact_hash,-aztec:randomness_singleton} DEBUG_COLORS: 1 CHAIN_ID: 31337 VERSION: 1 @@ -34,8 +34,8 @@ services: # need to run bb for proofs and bb is only built for x86 platform: linux/amd64 environment: - LOG_LEVEL: info - DEBUG: aztec:* + LOG_LEVEL: ${LOG_LEVEL:-info} + DEBUG: ${DEBUG:-aztec:*,-json-rpc:*,-aztec:circuits:artifact_hash,-aztec:randomness_singleton,-aztec:avm_simulator:*} DEBUG_COLORS: 1 CHAIN_ID: 31337 VERSION: 1 diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 96748862412..3656a356d9a 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -86,7 +86,6 @@ "stream-browserify": "^3.0.0", "ts-loader": "^9.4.4", "ts-node": "^10.9.1", - "tty-browserify": "^0.0.1", "typescript": "^5.0.4", "util": "^0.12.5", "webpack": "^5.88.2", diff --git a/yarn-project/aztec.js/webpack.config.js b/yarn-project/aztec.js/webpack.config.js index 5e56741b688..1b60153b54b 100644 --- a/yarn-project/aztec.js/webpack.config.js +++ b/yarn-project/aztec.js/webpack.config.js @@ -66,7 +66,6 @@ export default { buffer: require.resolve('buffer/'), util: require.resolve('util/'), stream: require.resolve('stream-browserify'), - tty: require.resolve('tty-browserify'), }, }, }; diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index b4c138967f7..1167abad54a 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -79,7 +79,6 @@ "ts-loader": "^9.4.4", "ts-node": "^10.9.1", "tslib": "^2.4.0", - "tty-browserify": "^0.0.1", "typescript": "^5.0.4", "util": "^0.12.5", "viem": "^2.7.15", diff --git a/yarn-project/end-to-end/webpack.config.js b/yarn-project/end-to-end/webpack.config.js index 6fe97604e7e..88f6bb5178c 100644 --- a/yarn-project/end-to-end/webpack.config.js +++ b/yarn-project/end-to-end/webpack.config.js @@ -64,7 +64,6 @@ export default { buffer: require.resolve('buffer/'), util: require.resolve('util/'), stream: require.resolve('stream-browserify'), - tty: require.resolve('tty-browserify'), }, }, }; diff --git a/yarn-project/foundation/src/crypto/random/randomness_singleton.ts b/yarn-project/foundation/src/crypto/random/randomness_singleton.ts index 667db265df1..f226874a921 100644 --- a/yarn-project/foundation/src/crypto/random/randomness_singleton.ts +++ b/yarn-project/foundation/src/crypto/random/randomness_singleton.ts @@ -18,10 +18,10 @@ export class RandomnessSingleton { private readonly log = createDebugLogger('aztec:randomness_singleton'), ) { if (seed !== undefined) { - this.log.verbose(`Using pseudo-randomness with seed: ${seed}`); + this.log.debug(`Using pseudo-randomness with seed: ${seed}`); this.counter = seed; } else { - this.log.verbose('Using true randomness'); + this.log.debug('Using true randomness'); } } diff --git a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts index 9c342805d09..60d07291cc0 100644 --- a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts +++ b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts @@ -25,7 +25,7 @@ export class JsonRpcServer { private objectClassMap: JsonClassConverterInput, /** List of methods to disallow from calling remotely */ public readonly disallowedMethods: string[] = [], - private log = createDebugLogger('aztec:foundation:json-rpc:server'), + private log = createDebugLogger('json-rpc:server'), ) { this.proxy = new JsonProxy(handler, stringClassMap, objectClassMap); } @@ -226,7 +226,7 @@ export type ServerList = { */ export function createNamespacedJsonRpcServer( servers: ServerList, - log = createDebugLogger('aztec:foundation:json-rpc:multi-server'), + log = createDebugLogger('json-rpc:multi-server'), ): JsonRpcServer { const handler = {} as any; const disallowedMethods: string[] = []; diff --git a/yarn-project/foundation/src/log/logger.ts b/yarn-project/foundation/src/log/logger.ts index b2cfbc31b39..3b28a279d2c 100644 --- a/yarn-project/foundation/src/log/logger.ts +++ b/yarn-project/foundation/src/log/logger.ts @@ -1,6 +1,4 @@ import debug from 'debug'; -import isNode from 'detect-node'; -import { isatty } from 'tty'; import { type LogData, type LogFn } from './log_fn.js'; @@ -15,6 +13,9 @@ export type LogLevel = (typeof LogLevels)[number]; const envLogLevel = process.env.LOG_LEVEL?.toLowerCase() as LogLevel; const currentLevel = LogLevels.includes(envLogLevel) ? envLogLevel : DefaultLogLevel; +const namespaces = process.env.DEBUG ?? 'aztec:*'; +debug.enable(namespaces); + /** Log function that accepts an exception object */ type ErrorLogFn = (msg: string, err?: Error | unknown, data?: LogData) => void; @@ -38,9 +39,6 @@ export type DebugLogger = Logger; */ export function createDebugLogger(name: string): DebugLogger { const debugLogger = debug(name); - if (currentLevel === 'debug') { - debugLogger.enabled = true; - } const logger = { silent: () => {}, @@ -78,42 +76,11 @@ function logWithDebug(debug: debug.Debugger, level: LogLevel, msg: string, data? } msg = data ? `${msg} ${fmtLogData(data)}` : msg; - if (debug.enabled) { - if (level !== 'debug') { - msg = `${level.toUpperCase()} ${msg}`; - } - debug(msg); - } else if (LogLevels.indexOf(level) <= LogLevels.indexOf(currentLevel)) { - printLog(`${getPrefix(debug, level)} ${msg}`); + if (debug.enabled && LogLevels.indexOf(level) <= LogLevels.indexOf(currentLevel)) { + debug('[%s] %s', level.toUpperCase(), msg); } } -/** - * Returns a log prefix that emulates that of npm debug. Uses colors if in node and in a tty. - * @param debugLogger - Instance of npm debug logger. - * @param level - Intended log level (printed out if strictly above current log level). - * @returns Log prefix. - */ -function getPrefix(debugLogger: debug.Debugger, level: LogLevel) { - const levelLabel = currentLevel !== level ? ` ${level.toUpperCase()}` : ''; - const prefix = `${debugLogger.namespace.replace(/^aztec:/, '')}${levelLabel}`; - if ((!isNode || !isatty(process.stderr.fd)) && !process.env.DEBUG_COLORS) { - return prefix; - } - const colorIndex = debug.selectColor(debugLogger.namespace) as number; - const colorCode = '\u001B[3' + (colorIndex < 8 ? colorIndex : '8;5;' + colorIndex); - return ` ${colorCode};1m${prefix}\u001B[0m`; -} - -/** - * Outputs to console error. - * @param msg - What to log. - */ -function printLog(msg: string) { - // eslint-disable-next-line no-console - isNode ? process.stderr.write(msg + '\n') : console.error(msg); -} - /** * Concatenates a log message and an exception. * @param msg - Log message diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index cc328c7abd1..3b6e8061c0d 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -158,7 +158,6 @@ __metadata: ts-loader: ^9.4.4 ts-node: ^10.9.1 tslib: ^2.4.0 - tty-browserify: ^0.0.1 typescript: ^5.0.4 util: ^0.12.5 webpack: ^5.88.2 @@ -464,7 +463,6 @@ __metadata: ts-loader: ^9.4.4 ts-node: ^10.9.1 tslib: ^2.4.0 - tty-browserify: ^0.0.1 typescript: ^5.0.4 util: ^0.12.5 viem: ^2.7.15 @@ -13608,13 +13606,6 @@ __metadata: languageName: node linkType: hard -"tty-browserify@npm:^0.0.1": - version: 0.0.1 - resolution: "tty-browserify@npm:0.0.1" - checksum: 93b745d43fa5a7d2b948fa23be8d313576d1d884b48acd957c07710bac1c0d8ac34c0556ad4c57c73d36e11741763ef66b3fb4fb97b06b7e4d525315a3cd45f5 - languageName: node - linkType: hard - "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0"