feat: add feature-gated tracing/logging infrastructure#4
Merged
tmthecoder merged 3 commits intomainfrom Feb 8, 2026
Merged
Conversation
- Add tracing and tracing-subscriber as optional dependencies to smb-core and smb - Create feature-gated logging macro wrappers in smb-core/src/logging.rs (no-ops when tracing feature is disabled) - Replace all println! calls with appropriate tracing macros across 18 files: - error!: unrecoverable failures in handler chain - warn!: parse failures, degraded behavior - info!: server start, connection accepted, session setup complete - debug!: command dispatch, handler delegation, message send/receive - trace!: sensitive data (keys, signatures, raw buffers, NTLM flags) - Clean up all commented-out println! calls in smb-core, smb-derive, smb - Initialize tracing-subscriber in main.rs behind #[cfg(feature = "tracing")] with RUST_LOG env var support, defaulting to info level - Features are fully independent and opt-in: - server: async runtime only, no tracing forced - tracing: structured tracing + subscriber - logging: tracing + log crate compatibility bridge
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
Replace all
println!calls with structuredtracingmacros and add a feature-gated logging infrastructure that library consumers can opt into without being burdened by unnecessary dependencies.Changes
Infrastructure
smb-core/src/logging.rs— New module with feature-gated macro wrappers. Whentracingis enabled, re-exportstracing::{trace, debug, info, warn, error, info_span, debug_span, trace_span}. When disabled, all macros compile to no-ops.smb-core/Cargo.toml— Addedtracingas optional dependency withtracingandloggingfeatures.smb/Cargo.toml— Addedtracingandtracing-subscriberas optional dependencies. Features are fully independent and opt-in.Features (all opt-in, none forced by
server)servertokio,tokio-stream,tokio-util) — no tracingtracingtracingcrate +tracing-subscriberloggingtracing+logcrate compatibility bridgeLog level conventions
error!warn!info!debug!trace!Files modified (26 files, 331 insertions, 95 deletions)
New:
smb-core/src/logging.rsprintln! → tracing (18 files):
smb/src/server/connection.rs,session.rs,mod.rs,message_handler.rs,tree_connect.rs,share/file_system.rssmb/src/socket/message_stream/mod.rs,stream_async.rssmb/src/protocol/message.rs,body/negotiate/context.rs,body/create/request_context.rs,body/create/response_context.rs,body/tree_connect/buffer.rssmb/src/util/auth/spnego/der_utils.rs,spnego_token.rs,spnego_token_response.rssmb/src/util/auth/ntlm/ntlm_authenticate_message.rssmb/src/main.rs— subscriber init behind#[cfg(feature = "tracing")], defaults toRUST_LOG=infoCommented-out println! cleanup (4 files):
smb-core/src/lib.rs,smb-derive/src/attrs.rs,field.rs,field_mapping.rsVerification
cargo check -p smb-core✅cargo check -p smb-core --features tracing✅cargo check -p smb-derive✅cargo check -p smb_reader --features server✅ (no tracing)cargo check -p smb_reader --features "server,tracing"✅cargo check --bin spin_server_up --features "server,tracing,anyhow"✅grep -r println! */src/— zero results