program-log: Add new crate#356
Merged
febo merged 47 commits intoanza-xyz:masterfrom Oct 9, 2025
Merged
Conversation
* Add log standalone crate * Refactored * Fix return value * Remove additional crate * Tidy up * Use memcpy * Improve digit formatting * Improve slice formatting * Improve comments * Add readme * Update README.md * Update README.md * Remove doctests * Use workspace values
* Add precision argument * Add std feature * Add std feature cfg * Add precision to solana target * Add precision support for signed types * Add inline * Update docs * Fix slice offset * Fix delta for signed values * Fix doc tests
* Add precision formatting * Remove lazy lock * Add precision formatting details * Update banner image * Add subtitle
* Bump version * Inline never * Add precision support to str * Add trucated attributes
* Add truncate format parsing * Add formatting options
* Fix typo * Add support for usize and isize * Improve sign conversion * Add tests * Simplify isize handling
* Avoid duplicate crates * Fix vulnerable package
* Update README.md * Update README.md * Update README.md
* [wip]: Address review comments * [wip]: Fix pointer reference * [wip]: Add logger buffer size tests * Remove unused * More logger tests * Rename program to cpi * Remove dynamic allocation * Fixed signed tests * Fix review comments * Fix unsigned test case * Add is_owner_by helper
* Update readme * Add docs * Fix link
Use alloc
Add rust version
fix typos README.md
* Tweaks * Add bool support
* fix: make sol_log_ call public * fix: logger formatting
* feat: add compute_fn proc_macro_attribute * WIP: use sol_remaining_compute_units syscall for calc * docs: actualize docs and add introspection cost comment * refactor: add static-syscall, remove dep on pinocchio from log, rename compute_fn -> log_cu_usage * fix: correct comment * fix: ci format step
* Calculate max digits * Remove second const Co-authored-by: Jon C <me@jonc.dev> --------- Co-authored-by: Jon C <me@jonc.dev>
* Add invoke instruction helper * Typos * Remove new helpers * Remove unused * Address review comments * Tweak inline attributes * Use invoke signed unchecked * Refactor inline * Renamed to with_bounds * Update docs * Revert change * Add constant length check * Add spellcheck step * Tweak action * Fix typos * More fixes * Yet more fixes * Fixes * Add j1 option * More and more fixes * Add missing acronym * Fix merge * Fix spelling * Fix spelling
* Add precision cap * Add tests * Refactor precision logic * Fix miri warning * Avoid duplication * Add missing syscall * More tests * Fix truncate logic * Fix review comments
Updated README to correct links and improve formatting.
ab0b1fe to
94e75bb
Compare
94e75bb to
ac253fd
Compare
joncinque
reviewed
Oct 8, 2025
Collaborator
joncinque
left a comment
There was a problem hiding this comment.
Looks great! I'm assuming the code is the same as in pinocchio, so I focused on integrating this in the repo
Contributor
Author
Yes, the code is the same. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Currently, logging messages that require formatting are a bit heavy on the CU consumption. For example, a simple
msg!("lamports={}", lamports)log can take~627CUs.Solution
Create a lightweight
log!macro that improves CU consumption.Below is a sample of the improvements observed when formatting log messages, measured in terms of compute units (CU):
log!msg!"Hello world!""lamports={}"+u64"{}"+[&str; 2]"lamports={}"+i64"{}"+[u8; 32](address bytes)"lamports={:.9}"+u64**Formsg!, the value is logged as af64otherwise the precision formatting is ignored.