Skip to content

Commit 29b4958

Browse files
authored
chore(docs): add public logging caveat and log module format (#17851)
2 parents a2a6e5d + e50dfb4 commit 29b4958

File tree

2 files changed

+91
-39
lines changed

2 files changed

+91
-39
lines changed

docs/docs/developers/docs/guides/local_env/how_to_debug.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LOG_LEVEL=debug aztec start --sandbox
2525
LOG_LEVEL="verbose;info:sequencer" aztec start --sandbox
2626
```
2727

28-
## Log in Aztec.nr contracts
28+
## Logging in Aztec.nr contracts
2929

3030
Log values from your contract using `debug_log`:
3131

@@ -46,27 +46,42 @@ debug_log_field(my_field);
4646
debug_log_array(my_array);
4747
```
4848

49-
Due to local execution of functions on Aztec, you can only see these logs when running private functions or simulating public functions.
49+
:::note
50+
Debug logs appear only during local execution. Private functions always execute locally, but public functions must be simulated to show logs. Use `.simulate()` or `.prove()` in TypeScript, or `env.simulate_public_function()` in TXE tests.
51+
:::
5052

51-
Enable logs on the wallet. For example, if your contract uses `TestWallet`:
53+
To see debug logs from your tests, set `LOG_LEVEL` when running:
5254

53-
```js
54-
await TestWallet.create(node)
55+
```bash
56+
LOG_LEVEL="debug" yarn run test
5557
```
5658

57-
Set the `LOG_LEVEL` on whatever is running it:
59+
To filter specific modules, use a semicolon-delimited list:
5860

5961
```bash
60-
LOG_LEVEL="debug" yarn run test
62+
LOG_LEVEL="info;debug:simulator:client_execution_context;debug:simulator:client_view_context" yarn run test
6163
```
6264

63-
This prints your `debug_logs` together with your application logs. You can further narrow it down by showing only the `execution` and `view` logs:
65+
:::info Log filter format
66+
`LOG_LEVEL` accepts a semicolon-delimited list of filters. Each filter can be:
67+
68+
- `level` - Sets default level for all modules
69+
- `level:module` - Sets level for a specific module
70+
- `level:module:submodule` - Sets level for a specific submodule
6471

6572
```bash
66-
LOG_LEVEL="info;debug:simulator:client_execution_context;debug:simulator:client_view_context" yarn run test
73+
# Default level only
74+
LOG_LEVEL="debug"
75+
76+
# Default level + specific module overrides
77+
LOG_LEVEL="info;debug:simulator;debug:execution"
78+
79+
# Default level + specific submodule overrides
80+
LOG_LEVEL="info;debug:simulator:client_execution_context;debug:simulator:client_view_context"
6781
```
82+
:::
6883

69-
## Debug common errors
84+
## Debugging common errors
7085

7186
### Contract Errors
7287

@@ -102,7 +117,7 @@ aztec-wallet send transfer --from test0 --to test0 --amount 0
102117
# Messages need 2 blocks to be processed
103118
```
104119

105-
## Debug WASM errors
120+
## Debugging WASM errors
106121

107122
### Enable debug WASM
108123

@@ -157,7 +172,7 @@ Current limits that trigger `7009 - ARRAY_OVERFLOW`:
157172
- Max function calls: Check call stack size limits
158173
- Max L2→L1 messages: Check message limits
159174

160-
## Debug sequencer issues
175+
## Debugging sequencer issues
161176

162177
### Common sequencer errors
163178

@@ -168,7 +183,7 @@ Current limits that trigger `7009 - ARRAY_OVERFLOW`:
168183
| `Public call stack size exceeded` | Too many public calls | Reduce public function calls |
169184
| `Failed to publish block` | L1 submission failed | Check L1 connection and gas |
170185

171-
## Report issues
186+
## Reporting issues
172187

173188
When debugging fails:
174189

docs/versioned_docs/version-v2.0.2/developers/docs/guides/local_env/how_to_debug.md

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
---
2-
title: How to Debug
2+
title: Debugging Aztec Code
33
sidebar_position: 5
44
tags: [debugging, errors, logging, sandbox, aztec.nr]
55
description: This guide shows you how to debug issues in your Aztec contracts.
66
---
77

88
This guide shows you how to debug issues in your Aztec development environment.
99

10-
**Prerequisites:**
10+
## Prerequisites
1111

12-
- Aztec sandbox running
12+
- Running Aztec sandbox
1313
- Aztec.nr contract or aztec.js application
1414
- Basic understanding of Aztec architecture
1515

16-
## How to Enable Logging
16+
## Enable logging
1717

18-
### In Aztec.nr Contracts
18+
Enable different levels of logging on the sandbox or local node by setting `LOG_LEVEL`:
19+
20+
```bash
21+
# Set log level (options: fatal, error, warn, info, verbose, debug, trace)
22+
LOG_LEVEL=debug aztec start --sandbox
23+
24+
# Different levels for different services
25+
LOG_LEVEL="verbose;info:sequencer" aztec start --sandbox
26+
```
27+
28+
## Logging in Aztec.nr contracts
29+
30+
Log values from your contract using `debug_log`:
1931

2032
```rust
2133
// Import debug logging
@@ -34,17 +46,42 @@ debug_log_field(my_field);
3446
debug_log_array(my_array);
3547
```
3648

37-
### In Sandbox
49+
:::note
50+
Debug logs appear only during local execution. Private functions always execute locally, but public functions must be simulated to show logs. Use `.simulate()` or `.prove()` in TypeScript, or `env.simulate_public_function()` in TXE tests.
51+
:::
52+
53+
To see debug logs from your tests, set `LOG_LEVEL` when running:
3854

3955
```bash
40-
# Set log level (options: fatal, error, warn, info, verbose, debug, trace)
41-
LOG_LEVEL=debug aztec start --sandbox
56+
LOG_LEVEL="debug" yarn run test
57+
```
4258

43-
# Different levels for different services
44-
LOG_LEVEL="verbose;info:sequencer" aztec start --sandbox
59+
To filter specific modules, use a semicolon-delimited list:
60+
61+
```bash
62+
LOG_LEVEL="info;debug:simulator:client_execution_context;debug:simulator:client_view_context" yarn run test
63+
```
64+
65+
:::info Log filter format
66+
`LOG_LEVEL` accepts a semicolon-delimited list of filters. Each filter can be:
67+
68+
- `level` - Sets default level for all modules
69+
- `level:module` - Sets level for a specific module
70+
- `level:module:submodule` - Sets level for a specific submodule
71+
72+
```bash
73+
# Default level only
74+
LOG_LEVEL="debug"
75+
76+
# Default level + specific module overrides
77+
LOG_LEVEL="info;debug:simulator;debug:execution"
78+
79+
# Default level + specific submodule overrides
80+
LOG_LEVEL="info;debug:simulator:client_execution_context;debug:simulator:client_view_context"
4581
```
82+
:::
4683

47-
## How to Debug Common Errors
84+
## Debugging common errors
4885

4986
### Contract Errors
5087

@@ -80,9 +117,9 @@ aztec-wallet send transfer --from test0 --to test0 --amount 0
80117
# Messages need 2 blocks to be processed
81118
```
82119

83-
## How to Debug WASM Errors
120+
## Debugging WASM errors
84121

85-
### Enable Debug WASM
122+
### Enable debug WASM
86123

87124
```javascript
88125
// In vite.config.ts or similar
@@ -93,7 +130,7 @@ export default {
93130
};
94131
```
95132

96-
### Profile Transactions
133+
### Profile transactions
97134

98135
```javascript
99136
import { serializePrivateExecutionSteps } from "@aztec/stdlib";
@@ -117,16 +154,16 @@ link.click();
117154

118155
⚠️ **Warning:** Debug files may contain private data. Use only in development.
119156

120-
## How to Interpret Error Messages
157+
## Interpret error messages
121158

122-
### Kernel Circuit Errors (2xxx)
159+
### Kernel circuit errors (2xxx)
123160

124161
- **Private kernel errors (2xxx)**: Issues with private function execution
125162
- **Public kernel errors (3xxx)**: Issues with public function execution
126163
- **Rollup errors (4xxx)**: Block production issues
127164
- **Generic errors (7xxx)**: Resource limits or state validation
128165

129-
### Transaction Limits
166+
### Transaction limits
130167

131168
Current limits that trigger `7009 - ARRAY_OVERFLOW`:
132169

@@ -135,9 +172,9 @@ Current limits that trigger `7009 - ARRAY_OVERFLOW`:
135172
- Max function calls: Check call stack size limits
136173
- Max L2→L1 messages: Check message limits
137174

138-
## How to Debug Sequencer Issues
175+
## Debugging sequencer issues
139176

140-
### Common Sequencer Errors
177+
### Common sequencer errors
141178

142179
| Error | Cause | Solution |
143180
| ------------------------------------ | --------------------- | ------------------------------------------ |
@@ -146,7 +183,7 @@ Current limits that trigger `7009 - ARRAY_OVERFLOW`:
146183
| `Public call stack size exceeded` | Too many public calls | Reduce public function calls |
147184
| `Failed to publish block` | L1 submission failed | Check L1 connection and gas |
148185

149-
## How to Report Issues
186+
## Reporting issues
150187

151188
When debugging fails:
152189

@@ -155,28 +192,28 @@ When debugging fails:
155192
3. Note your environment setup
156193
4. Create issue at [aztec-packages](https://github.com/AztecProtocol/aztec-packages/issues/new)
157194

158-
## Quick Reference
195+
## Quick reference
159196

160-
### Enable Verbose Logging
197+
### Enable verbose logging
161198

162199
```bash
163200
LOG_LEVEL=verbose aztec start --sandbox
164201
```
165202

166-
### Common Debug Imports
203+
### Common debug imports
167204

168205
```rust
169206
use dep::aztec::oracle::debug_log::{ debug_log, debug_log_format };
170207
```
171208

172-
### Check Contract Registration
209+
### Check contract registration
173210

174211
```javascript
175212
await pxe.getContracts();
176213
await pxe.getRegisteredAccounts();
177214
```
178215

179-
### Decode L1 Errors
216+
### Decode L1 errors
180217

181218
Check hex errors against [Errors.sol](https://github.com/AztecProtocol/aztec-packages/blob/master/l1-contracts/src/core/libraries/Errors.sol)
182219

@@ -188,7 +225,7 @@ Check hex errors against [Errors.sol](https://github.com/AztecProtocol/aztec-pac
188225
- Use debug WASM for detailed stack traces
189226
- Profile transactions when errors are unclear
190227

191-
## Related Resources
228+
## Next steps
192229

193230
- [Circuit Architecture](../../concepts/advanced/circuits/index.md)
194231
- [Private-Public Execution](../../concepts/smart_contracts/functions/public_private_calls.md)

0 commit comments

Comments
 (0)