Skip to content

feat: nicer contract debug logs + minor related cleanup#19960

Merged
benesjan merged 1 commit intonextfrom
01-27-feat_separate_contract_log_channel
Feb 9, 2026
Merged

feat: nicer contract debug logs + minor related cleanup#19960
benesjan merged 1 commit intonextfrom
01-27-feat_separate_contract_log_channel

Conversation

@benesjan
Copy link
Contributor

@benesjan benesjan commented Jan 27, 2026

In this PR I refactor how logs emitted from contracts are handled:

  • I register a contract_log module that is treated differently in that it has the default log level set to "debug". This ensures that by default Noir contract devs will see their logs printed out no matter the "system-wide" default log level (this was a common source of confusion for devs). Note that this results in dev needing to set export LOG_LEVEL="silent;silent:contract_log" to truly silence all logs. This feels controversial but I feel like it's currently the best tradeoff as devs were confused of not seeing their contract logs (contract logs are generally also not that spammy). Update: As mentioned below this is not the way to go and will be handled differnetly.
  • I make the emitted logs nicer by having them include name and first few bytes of address:
image

Followup work

  • Rename the utilityDebugLog handler as utilityLog and clean up the noir-projects/noir-protocol-circuits/crates/types/src/debug_log.nr file that is now in a sad state,
  • make the nice contract logs work in public as well (this is currently broken).

@benesjan benesjan force-pushed the 01-27-feat_separate_contract_log_channel branch from 42dd819 to 30a5a7a Compare January 27, 2026 07:37
Copy link
Contributor Author

benesjan commented Jan 27, 2026

@benesjan benesjan force-pushed the 01-27-feat_separate_contract_log_channel branch 2 times, most recently from f5c7c2a to 94de4d8 Compare February 9, 2026 09:46
@benesjan benesjan force-pushed the 01-27-feat_separate_contract_log_channel branch from 56e183f to 1e47bef Compare February 9, 2026 10:29
@benesjan benesjan marked this pull request as ready for review February 9, 2026 10:49
@benesjan benesjan changed the title feat: separate contract log channel feat: nicer contract debug logs Feb 9, 2026
@AztecBot
Copy link
Collaborator

AztecBot commented Feb 9, 2026

Flakey Tests

🤖 says: This CI run detected 3 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/72ac13139cf22a33�72ac13139cf22a338;;�): yarn-project/scripts/run_test.sh p2p/src/client/test/p2p_client.integration_message_propagation.test.ts (23s) (code: 1) group:e2e-p2p-epoch-flakes
\033FLAKED\033 (8;;http://ci.aztec-labs.com/00e9718442e424aa�00e9718442e424aa8;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/duplicate_proposal_slash.test.ts (493s) (code: 1) group:e2e-p2p-epoch-flakes
\033FLAKED\033 (8;;http://ci.aztec-labs.com/d7a91fb9eb76fe1d�d7a91fb9eb76fe1d8;;�): ./boxes/scripts/run_test.sh vite chromium (601s) (code: 124)

@benesjan benesjan requested a review from spalladino February 9, 2026 11:25
@benesjan benesjan changed the title feat: nicer contract debug logs feat: nicer contract debug logs + minor related cleanup Feb 9, 2026
Comment on lines +131 to +134
// We give special treatment to contract logs because we want all the contract logs to be emitted no matter the default
// log level. This is because we don't want Noir contract developers to have to modify env vars to see logs come out of
// contracts. This default setting for the contract logs can be explicitly overridden via the LOG_LEVEL (e.g. to
// silence contract logs export 'info;silent:contract_log').
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll push back on this. It's going to be annoying for anyone who is not a noir contract dev - if I've set up log level to info, then why am I seeing debug?

I'd look for alternatives, such as bumping the log level of contracts to info (or something that noir contract devs usually run with), or having the TXE manually bump the log level for this module (eg when creating the logger for the utility execution oracle, I'm not sure if we support individual loggers having different log levels, but shouldn't be hard to implement), or only doing this if a certain env var is set (and not by default).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a point. Dropped this in d80da3d

I will instead ensure this is correctly set when running aztec test and will try to figure out how to make people realize they should set this in e2e tests. Will do this in a followup PR.

Comment on lines +363 to +365
const name = await this.contractStore.getDebugContractName(this.contractAddress);
const module = name ? `contract_log::${name}(${addrAbbrev})` : `contract_log::${addrAbbrev}`;
this.contractLogger = createLogger(module);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #19959 we have an instanceId that we can attach to a logger. Seems like that would be a perfect fit for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not aware of that. Lovely feature. Thanks!

47f99c2

@benesjan benesjan marked this pull request as draft February 9, 2026 14:01
@benesjan benesjan marked this pull request as ready for review February 9, 2026 15:07
@benesjan benesjan requested a review from spalladino February 9, 2026 15:07
@benesjan benesjan enabled auto-merge February 9, 2026 15:08
In this PR I refactor how logs emitted from contracts are handled:
- ~I register a `contract_log` module that is treated differently in that it has the default log level set to "debug". This ensures that by default Noir contract devs will see their logs printed out no matter the "system-wide" default log level (this was a common source of confusion for devs). Note that this results in dev needing to set `export LOG_LEVEL="silent;silent:contract_log"` to truly silence all logs. This feels controversial but I feel like it's currently the best tradeoff as devs were confused of not seeing their contract logs (contract logs are generally also not that spammy).~
- I make the emitted logs nicer by having them include name and first few bytes of address:

<img width="1260" height="470" alt="image" src="https://github.com/user-attachments/assets/b3a14cbe-d55e-44bf-9ae5-e26f3e1f35de" />

## Followup work
- Rename the `utilityDebugLog` handler as `utilityLog` and clean up the `noir-projects/noir-protocol-circuits/crates/types/src/debug_log.nr` file that is now in a sad state,
- make the nice contract logs work in public as well (this is currently broken).
@AztecBot AztecBot force-pushed the 01-27-feat_separate_contract_log_channel branch from 47f99c2 to 166c4d6 Compare February 9, 2026 15:58
@benesjan benesjan added this pull request to the merge queue Feb 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 9, 2026
@benesjan
Copy link
Contributor Author

benesjan commented Feb 9, 2026

CI failure seems to be an issue with foundry server so I'm re-adding.

@benesjan benesjan added this pull request to the merge queue Feb 9, 2026
Merged via the queue into next with commit cefddef Feb 9, 2026
22 checks passed
@benesjan benesjan deleted the 01-27-feat_separate_contract_log_channel branch February 9, 2026 18:20
AztecBot pushed a commit that referenced this pull request Feb 11, 2026
The `debug_log` naming became problematic as different log levels are supported and hence the name collides with the debug log level even though it's a generic util.

For this reason I've renamed `debug_log` simply as `log` and I've cleaned up what used to be `debug_log.nr` file (in this PR renamed to `logging.nr`). The cleanup consists of:
- dropping the log_slice functions (use of slices is now discouraged),
- introducing individual functions for different log levels,
- un-exposing the log level constants (the specific functions should be used instead)

This is a breaking change as the imports need to get updated.

This PR is a followup of #19960
AztecBot pushed a commit that referenced this pull request Feb 11, 2026
The `debug_log` naming became problematic as different log levels are supported and hence the name collides with the debug log level even though it's a generic util.

For this reason I've renamed `debug_log` simply as `log` and I've cleaned up what used to be `debug_log.nr` file (in this PR renamed to `logging.nr`). The cleanup consists of:
- dropping the log_slice functions (use of slices is now discouraged),
- introducing individual functions for different log levels,
- un-exposing the log level constants (the specific functions should be used instead)

This is a breaking change as the imports need to get updated.

This PR is a followup of #19960
github-merge-queue bot pushed a commit that referenced this pull request Feb 11, 2026
The `debug_log` naming became problematic as different log levels are
supported and hence the name collides with the debug log level even
though it's a generic util.

For this reason I've renamed `debug_log` simply as `log` and I've
cleaned up what used to be `debug_log.nr` file (in this PR renamed to
`logging.nr`). The cleanup consists of:
- dropping the log_slice functions (use of slices is now discouraged),
- introducing individual functions for different log levels,
- un-exposing the log level constants (the specific functions should be
used instead)

This is a breaking change as the imports need to get updated.

This PR is a followup of
#19960
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants