Skip to content

Commit c246aba

Browse files
chore!: Remove debug and winston in favor of pino (#10355)
First steps for logging cleanup. Removes all traces of `debug` and `winston` in favor of `pino`. Fixes #10118 ## Breaking changes - `DEBUG` variable is no longer used. Instead, overloads `LOG_LEVEL` by allowing a list of modules to have non-default log levels. For example, `LOG_LEVEL="info; verbose: aztec:sequencer, aztec:archiver; debug: aztec:kv-store"` sets `info` as the default log level, `verbose` for the sequencer and archiver, and `debug` for the kv-store. Match is by prefix. ## Levels Defines the following logging levels, all of them standard in pino, except for `verbose` which we already used extensively before: - fatal: Use when an error has brought down the system. - error: Use for errors in general. - warn: Use for when we stray from the happy path. - info: Use for providing an operator with info on what the system is doing. - verbose: Use for when we need additional insight on what a subsystem is doing. - debug: Use for when we need debugging info to troubleshoot an issue on a specific component. - trace: Use for when we want to denial-of-service any recipient of the logs. Fixes #10116 ## Filtering Removes usage of the `DEBUG` env var for log filtering. Instead, overloads `LOG_LEVEL` by allowing a list of modules to have non-default log levels. For example, `LOG_LEVEL="info; verbose: aztec:sequencer, aztec:archiver; debug: aztec:kv-store"` sets `info` as the default log level, `verbose` for the sequencer and archiver, and `debug` for the kv-store. Match is by prefix. Fixes #10119 ## OTEL integration Vendors the OTEL pino stream from `openetelemetry/instrumentation-pino` and configures it as an additional transport if the `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` env var is set. Using the instrumentation-pino directly would have required buying in fully into the opentelemetry node sdk, which we preferred to avoid so we have more fine-grained control, and it also pollutes the main worker thread. Instead, we vendor the stream code and initialize it within a transport, which runs it on a worker thread. As for log correlation, instead of having `instrumentation-pino` monkey-patch pino, we wrap the call to the logger to manually inject the trace and span id, which ensures that tempo can load the relevant logs for a trace in loki. https://github.com/user-attachments/assets/9421a22f-4c5a-49f7-80da-ab3e14d323ba Fixes #10121 Fixes #10123 ## Pretty logs Pino logs to json by default, but if `LOG_JSON` is not set, we programmatically set up `pino-pretty` for console logging. Looks like this: ![image](https://github.com/user-attachments/assets/3d547a25-b5a7-49b8-b4a3-9be00e1fa268) Fixes #10126 ## DEBUG settings Given we no longer use `DEBUG`, we remove this variable from most scripts. Since we were using modules to silence some noisy namespaces, we tweak those calls to be passed as `trace` instead, so we can enable debug without fear of being bombarded. For reference, the default `DEBUG` string used in scripts was: ``` aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream* ``` --------- Co-authored-by: Mitch <mitchell@aztecprotocol.com>
1 parent 5299481 commit c246aba

File tree

84 files changed

+1092
-978
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1092
-978
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This provide an interactive environment for debugging the CI test.
4747

4848
## Debugging
4949

50-
Logging goes through the [DebugLogger](yarn-project/foundation/src/log/debug.ts) module in Typescript. To see the log output, set a `DEBUG` environment variable to the name of the module you want to debug, to `aztec:*`, or to `*` to see all logs.
50+
Logging goes through the [DebugLogger](yarn-project/foundation/src/log/debug.ts) module in Typescript. `LOG_LEVEL` controls the default log level, and one can set alternate levels for specific modules, such as `debug; warn: module1, module2; error: module3`.
5151

5252
## Releases
5353

aztec-up/bin/.aztec-run

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ while [[ "$#" -gt 0 ]]; do
104104
done
105105

106106
DOCKER_ENV="-e HOME=$HOME"
107-
if ! [ -z "${DEBUG:-}" ] ; then
108-
DOCKER_ENV="-e DEBUG=$DEBUG"
107+
if ! [ -z "${LOG_LEVEL:-}" ] ; then
108+
DOCKER_ENV="-e LOG_LEVEL=$LOG_LEVEL"
109109
fi
110110
for env in ${ENV_VARS_TO_INJECT:-}; do
111111
# SSH_AUTH_SOCK must be handled separately

aztec-up/bin/docker-compose.sandbox.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
ports:
2121
- "${PXE_PORT:-8080}:${PXE_PORT:-8080}"
2222
environment:
23-
DEBUG: # Loaded from the user shell if explicitly set
23+
LOG_LEVEL: # Loaded from the user shell if explicitly set
2424
HOST_WORKDIR: "${PWD}" # Loaded from the user shell to show log files absolute path in host
2525
ETHEREUM_HOST: ${ETHEREUM_HOST:-http://ethereum}:${ANVIL_PORT:-8545}
2626
L1_CHAIN_ID: 31337

aztec-up/bin/docker-compose.test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ services:
22
txe:
33
image: "aztecprotocol/aztec"
44
environment:
5-
DEBUG: # Loaded from the user shell if explicitly set
65
LOG_LEVEL: # Loaded from the user shell if explicitly set
76
HOST_WORKDIR: "${PWD}" # Loaded from the user shell to show log files absolute path in host
87
volumes:

docker-compose.yml

-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ services:
66
platform: linux/amd64
77
environment:
88
LOG_LEVEL: ${LOG_LEVEL:-info}
9-
DEBUG: ${DEBUG:-aztec:*,-json-rpc:*,-aztec:circuits:artifact_hash,-aztec:randomness_singleton}
10-
DEBUG_COLORS: 1
119
L1_CHAIN_ID: 31337
1210
VERSION: 1
1311
PXE_PROVER_ENABLED: ${PXE_PROVER_ENABLED:-1}
@@ -38,8 +36,6 @@ services:
3836
platform: linux/amd64
3937
environment:
4038
LOG_LEVEL: ${LOG_LEVEL:-info}
41-
DEBUG: ${DEBUG:-aztec:*,-json-rpc:*,-aztec:circuits:artifact_hash,-aztec:randomness_singleton,-aztec:avm_simulator:*}
42-
DEBUG_COLORS: 1
4339
L1_CHAIN_ID: 31337
4440
VERSION: 1
4541
NODE_NO_WARNINGS: 1

docs/docs/migration_notes.md

+29
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@ keywords: [sandbox, aztec, notes, migration, updating, upgrading]
66

77
Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them.
88

9+
## 0.66
10+
11+
### DEBUG env var is removed
12+
13+
The `DEBUG` variable is no longer used. Use `LOG_LEVEL` with one of `silent`, `fatal`, `error`, `warn`, `info`, `verbose`, `debug`, or `trace`. To tweak log levels per module, add a list of module prefixes with their overridden level. For example, LOG_LEVEL="info; verbose: aztec:sequencer, aztec:archiver; debug: aztec:kv-store" sets `info` as the default log level, `verbose` for the sequencer and archiver, and `debug` for the kv-store. Module name match is done by prefix.
14+
15+
### `tty` resolve fallback required for browser bundling
16+
17+
When bundling `aztec.js` for web, the `tty` package now needs to be specified as an empty fallback:
18+
19+
```diff
20+
resolve: {
21+
plugins: [new ResolveTypeScriptPlugin()],
22+
alias: { './node/index.js': false },
23+
fallback: {
24+
crypto: false,
25+
os: false,
26+
fs: false,
27+
path: false,
28+
url: false,
29+
+ tty: false,
30+
worker_threads: false,
31+
buffer: require.resolve('buffer/'),
32+
util: require.resolve('util/'),
33+
stream: require.resolve('stream-browserify'),
34+
},
35+
},
36+
```
37+
938
## 0.65
1039

1140
### [aztec.nr] Removed SharedImmutable

docs/docs/reference/developer_references/debugging.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ debug_log_array(my_array);
5353

5454
### Start Sandbox in debug mode
5555

56-
Update the `DEBUG` environment variable in docker-compose.sandbox.yml to the following:
56+
Set `LOG_LEVEL` to `verbose` or `debug`:
5757

5858
```yml
5959
# ~/.aztec/docker-compose.sandbox.yml
@@ -65,8 +65,7 @@ aztec:
6565
ports:
6666
- "${PXE_PORT:-8080}:${PXE_PORT:-8080}"
6767
environment:
68-
DEBUG: aztec:simulator:client_execution_context, aztec:sandbox, aztec:avm_simulator:debug_log
69-
LOG_LEVEL: verbose # optionally add this for more logs
68+
LOG_LEVEL: verbose
7069
# ...
7170
```
7271

spartan/aztec-network/templates/deploy-l1-verifier.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ spec:
6262
env:
6363
- name: NODE_NO_WARNINGS
6464
value: "1"
65-
- name: DEBUG
66-
value: "aztec:*"
6765
- name: LOG_LEVEL
6866
value: "debug"
6967
- name: L1_CHAIN_ID

spartan/aztec-network/templates/prover-agent.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ spec:
8585
value: "{{ .Values.proverAgent.logLevel }}"
8686
- name: LOG_JSON
8787
value: "1"
88-
- name: DEBUG
89-
value: "{{ .Values.proverAgent.debug }}"
9088
- name: PROVER_REAL_PROOFS
9189
value: "{{ .Values.aztec.realProofs }}"
9290
- name: PROVER_AGENT_COUNT

spartan/aztec-network/templates/prover-broker.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ spec:
6666
value: "{{ .Values.proverBroker.logLevel }}"
6767
- name: LOG_JSON
6868
value: "1"
69-
- name: DEBUG
70-
value: "{{ .Values.proverBroker.debug }}"
7169
- name: PROVER_BROKER_POLL_INTERVAL_MS
7270
value: "{{ .Values.proverBroker.pollIntervalMs }}"
7371
- name: PROVER_BROKER_JOB_TIMEOUT_MS

spartan/aztec-network/templates/pxe.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ spec:
8484
value: "1"
8585
- name: LOG_LEVEL
8686
value: "{{ .Values.pxe.logLevel }}"
87-
- name: DEBUG
88-
value: "{{ .Values.pxe.debug }}"
8987
- name: PXE_PROVER_ENABLED
9088
value: "{{ .Values.aztec.realProofs }}"
9189
ports:

spartan/aztec-network/templates/setup-l2-contracts.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ spec:
6161
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts --skipProofWait --l1-chain-id {{ .Values.ethereum.chainId }}
6262
echo "L2 contracts initialized"
6363
env:
64-
- name: DEBUG
65-
value: "aztec:*"
6664
- name: LOG_LEVEL
6765
value: "debug"
6866
- name: NETWORK_PUBLIC

spartan/aztec-network/templates/transaction-bot.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ spec:
7979
value: "1"
8080
- name: LOG_LEVEL
8181
value: "{{ .Values.bot.logLevel }}"
82-
- name: DEBUG
83-
value: "{{ .Values.bot.debug }}"
8482
- name: BOT_PRIVATE_KEY
8583
value: "{{ .Values.bot.botPrivateKey }}"
8684
- name: BOT_TX_INTERVAL_SECONDS

spartan/aztec-network/values.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bootNode:
4545
p2pUdpPort: 40400
4646
nodePort: 8080
4747
logLevel: "debug"
48-
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
48+
debug: ""
4949
coinbaseAddress: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
5050
sequencer:
5151
maxSecondsBetweenBlocks: 0
@@ -88,7 +88,7 @@ validator:
8888
p2pUdpPort: 40400
8989
nodePort: 8080
9090
logLevel: "debug"
91-
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
91+
debug: ""
9292
sequencer:
9393
maxSecondsBetweenBlocks: 0
9494
minTxsPerBlock: 1
@@ -118,7 +118,7 @@ proverNode:
118118
p2pUdpPort: 40400
119119
nodePort: 8080
120120
logLevel: "debug"
121-
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
121+
debug: ""
122122
proverAgent:
123123
count: 0
124124
pollIntervalMs: 1000
@@ -137,7 +137,6 @@ proverNode:
137137

138138
pxe:
139139
logLevel: "debug"
140-
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
141140
replicas: 1
142141
service:
143142
nodePort: 8081
@@ -156,7 +155,6 @@ bot:
156155
enabled: true
157156
nodeUrl: ""
158157
logLevel: "debug"
159-
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:l2_block_stream,-aztec:world-state:database"
160158
replicas: 1
161159
botPrivateKey: "0xcafe"
162160
txIntervalSeconds: 24
@@ -217,7 +215,6 @@ proverAgent:
217215
gke:
218216
spotEnabled: false
219217
logLevel: "debug"
220-
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
221218
bb:
222219
hardwareConcurrency: ""
223220
nodeSelector: {}
@@ -233,7 +230,6 @@ proverBroker:
233230
jobMaxRetries: 3
234231
dataDirectory: ""
235232
logLevel: "debug"
236-
debug: "aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*"
237233
nodeSelector: {}
238234
resources: {}
239235

spartan/aztec-network/values/prover-node-with-agents.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ validator:
1212
external: true
1313

1414
bootNode:
15-
debug: "aztec:*,-aztec:avm_simulator:*,-aztec:world-state:database,discv5:*,-JsonProxy:*"
15+
debug: "discv5:*"
1616
validator:
1717
disabled: true
1818

spartan/releases/rough-rhino/aztec-spartan.sh

-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ services:
178178
- VALIDATOR_PRIVATE_KEY=${KEY}
179179
- SEQ_PUBLISHER_PRIVATE_KEY=${KEY}
180180
- L1_PRIVATE_KEY=${KEY}
181-
- DEBUG=aztec:*,-aztec:avm_simulator*,-aztec:circuits:artifact_hash,-aztec:libp2p_service,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*
182181
- LOG_LEVEL=debug
183182
- AZTEC_PORT=${PORT}
184183
- P2P_ENABLED=true

spartan/testnet-runbook.md

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Verbose logging on Aztec nodes should be enabled by default using the following
4545

4646
- `LOG_JSON=1`
4747
- `LOG_LEVEL=debug`
48-
- `DEBUG=discv5*,aztec:*,-aztec:avm_simulator*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:world-state:database,-aztec:l2_block_stream*`
4948

5049
Deployments are initiated from CI by manually running the (_name pending_) workflow.
5150

yarn-project/Earthfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,16 @@ test:
302302

303303
run-e2e:
304304
ARG test
305+
ARG log_level=""
305306
ARG debug=""
306307
FROM +end-to-end
307-
RUN DEBUG=$debug yarn test $test
308+
RUN DEBUG=$debug LOG_LEVEL=$log_level yarn test $test
308309

309310
prover-client-test:
310311
FROM +build
311312
ARG test
312-
ARG debug=""
313-
RUN cd prover-client && DEBUG=$debug yarn test $test
313+
ARG log_level=""
314+
RUN cd prover-client && LOG_LEVEL=$log_level yarn test $test
314315

315316
# NOTE: This is not in the end-to-end Earthfile as that is entirely LOCALLY commands that will go away sometime.
316317
# Running this inside the main builder as the point is not to run this through dockerization.

yarn-project/aztec-faucet/terraform/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ resource "aws_ecs_task_definition" "aztec-faucet" {
107107
value = "80"
108108
},
109109
{
110-
name = "DEBUG",
111-
value = "aztec:*"
110+
name = "LOG_LEVEL",
111+
value = "verbose"
112112
},
113113
{
114114
name = "RPC_URL",

yarn-project/aztec.js/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export { decodeFromAbi, encodeArguments, type AbiType } from '@aztec/foundation/
156156
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
157157
export { sha256 } from '@aztec/foundation/crypto';
158158
export { makeFetch } from '@aztec/foundation/json-rpc/client';
159-
export { createDebugLogger, onLog, type DebugLogger } from '@aztec/foundation/log';
159+
export { createDebugLogger, type DebugLogger } from '@aztec/foundation/log';
160160
export { retry, retryUntil } from '@aztec/foundation/retry';
161161
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
162162
export { sleep } from '@aztec/foundation/sleep';

yarn-project/aztec.js/webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default {
6161
fs: false,
6262
path: false,
6363
url: false,
64+
tty: false,
6465
worker_threads: false,
6566
buffer: require.resolve('buffer/'),
6667
util: require.resolve('util/'),

yarn-project/aztec/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
ports:
2222
- '${SANDBOX_PXE_PORT:-8080}:8080'
2323
environment:
24-
DEBUG: # Loaded from the user shell if explicitly set
24+
LOG_LEVEL: # Loaded from the user shell if explicitly set
2525
HOST_WORKDIR: '${PWD}' # Loaded from the user shell to show log files absolute path in host
2626
ETHEREUM_HOST: http://ethereum:8545
2727
L1_CHAIN_ID: 31337

yarn-project/aztec/package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
2323
"build:dev": "tsc -b --watch",
2424
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests",
25-
"run:example:token": "DEBUG='aztec:*' node ./dest/examples/token.js"
25+
"run:example:token": "LOG_LEVEL='verbose' node ./dest/examples/token.js"
2626
},
2727
"inherits": [
2828
"../package.common.json"
@@ -55,16 +55,13 @@
5555
"@aztec/telemetry-client": "workspace:^",
5656
"@aztec/txe": "workspace:^",
5757
"@aztec/types": "workspace:^",
58-
"@opentelemetry/winston-transport": "^0.7.0",
5958
"@types/chalk": "^2.2.0",
6059
"abitype": "^0.8.11",
6160
"chalk": "^5.3.0",
6261
"commander": "^12.1.0",
6362
"koa": "^2.14.2",
6463
"koa-router": "^12.0.0",
65-
"viem": "^2.7.15",
66-
"winston": "^3.10.0",
67-
"winston-daily-rotate-file": "^4.7.1"
64+
"viem": "^2.7.15"
6865
},
6966
"files": [
7067
"dest",
@@ -117,4 +114,4 @@
117114
"engines": {
118115
"node": ">=18"
119116
}
120-
}
117+
}

yarn-project/aztec/src/cli/cli.ts

-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { type DebugLogger, type LogFn } from '@aztec/foundation/log';
99

1010
import { Command } from 'commander';
1111

12-
import { setupConsoleJsonLog } from '../logging.js';
1312
import { createSandbox } from '../sandbox.js';
1413
import { github, splash } from '../splash.js';
1514
import { aztecStartOptions } from './aztec_start_options.js';
@@ -39,11 +38,6 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
3938
startCmd.helpInformation = printAztecStartHelpText;
4039

4140
startCmd.action(async options => {
42-
// setup json logging
43-
if (['1', 'true', 'TRUE'].includes(process.env.LOG_JSON ?? '')) {
44-
setupConsoleJsonLog();
45-
}
46-
4741
// list of 'stop' functions to call when process ends
4842
const signalHandlers: Array<() => Promise<void>> = [];
4943
const services: NamespacedApiHandlers = {};

0 commit comments

Comments
 (0)