feat: rename log macros to debug!/info!/warn!/error! + add trace level and spans#1
Merged
Conversation
91afbef to
04b99de
Compare
Rename level macros to align with the Rust logging ecosystem (log/tracing):
logd! -> debug!
logi! -> info!
logw! -> warn!
loge! -> error!
Add a new Trace severity (Level::TRC = 0) and trace! macro for the lowest
level. The existing levels shift up by one (DBG=1, INF=2, WRN=3, ERR=4,
OFF=5).
Add a lightweight span subsystem:
- core/src/span.rs: Span, SpanGuard, SpanId, StaticSpanInfo,
Instrument/Instrumented (future wrapper), thread-local span stack
(MAX_SPAN_DEPTH=64).
- span! macro for ergonomic creation.
- Header pattern gains a {span} token; renders "-" at the root and the
decimal span id when a span is entered.
Payload layout grows by 8 bytes:
[info_ptr][timestamp][span_id][encoded args...]
Note on argument order: span_id is placed at the *end* of write_record /
write_header signatures (not adjacent to level) so that thread_name and
location stay in AAPCS64 argument registers. An earlier in-middle
placement pushed &str length onto the stack and caused 60-140%
regressions on the header_output benches; moving span_id last restores
all benches to noise threshold (some hot-path cases now ~6% faster than
the pre-span baseline).
Verification:
- cargo check / clippy / test (71 tests): all green, includes 3 new
span and header tests.
- cargo bench (latency_throughput, core_component_bench,
ferrilog_bench): 0 regressed, 1 improved, rest within noise.
- Manual span smoke test: nested outer/inner spans render correct
{span} ids ("-" -> "1" -> "2" -> "1" -> "-").
04b99de to
73e06db
Compare
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.
Summary
logd!/logi!/logw!/loge!→debug!/info!/warn!/error!Level::TRC = 0) and atrace!macro; existing levels shift +1 (DBG=1, INF=2, WRN=3, ERR=4, OFF=5)Span,SpanGuard,SpanId,Instrumentfuture wrapper) with thespan!macro and a{span}header pattern tokenBreaking changes
logd!/logi!/logw!/loge!call sites must migrate todebug!/info!/warn!/error!. No deprecated aliases retained.Levelnumeric repr shifts: persisted/serialized level bytes from prior builds are no longer compatible (ferrilog has no on-disk Level serialization today, so this is internal-only).StaticHeaderWriteFnsignature gains a trailingu64(span_id). Any custom static header writer must add the parameter.Implementation notes
[info_ptr][timestamp][span_id][encoded args...]span_idis placed at the end ofwrite_record/write_headersignatures. An earlier in-middle placement caused 60–140% regressions on theheader_outputbenches because AAPCS64 spilled&str.lento the stack. Movingspan_idlast restores all benches to noise threshold and leavesthread_name/locationin argument registers.Test plan
cargo check --workspace --all-features --all-targetscargo test --workspace --all-features— 71 tests pass, includes newspan::tests::enter_and_drop_restore_current_span,span::tests::span_records_parent_id,header::tests::span_header_token_renders_dash_for_root_and_decimal_for_spancargo clippy --workspace --all-features --all-targets -- -D warnings— zero warningscargo bench(latency_throughput, core_component_bench, ferrilog_bench) — 0 regressed, 1 improved, rest within noise; some hot-path cases ~6% faster than the pre-span baselinespan=-→span=1→span=2→span=1→span=-correctly