Skip to content

Conversation

sohw400
Copy link

@sohw400 sohw400 commented Oct 13, 2025

Summary

Added structured logging to all pf-proxy components using the tracing crate. This replaces the basic println statements with proper logging infrastructure that's more suitable for production deployments.

Motivation

The roadmap mentions logging improvements for proxies in v0.11.0. Proxy components are critical infrastructure pieces that run long-lived processes, so having proper logging is essential for debugging and monitoring. The current println approach doesn't give operators enough control over log levels or output format.

Changes

Dependencies

  • Added tracing for structured logging
  • Added tracing-subscriber with env-filter support

All proxy binaries updated:

  • vsock-to-ip
  • ip-to-vsock
  • ip-to-vsock-transparent
  • vsock-to-ip-transparent
  • transparent-port-to-vsock
  • addr_info utility module

Logging improvements:

  • Replaced println with info! macros for normal operations
  • Replaced error prints with error! macros
  • Added structured fields (from/to addresses, direction, error context)
  • Logs are now filterable via RUST_LOG environment variable
  • Default level is info, can be adjusted per-module if needed

Usage

Set log level via environment variable:

RUST_LOG=debug ./vsock-to-ip -v 3:8000 -i 127.0.0.1:8000
RUST_LOG=pf_proxy=trace ./ip-to-vsock -i 0.0.0.0:4000 -v 88:4000

Testing

Verified all binaries compile and logging format looks good. The structured fields make it easy to filter logs by connection direction, addresses, etc.

- Update outdated dependencies: clap 3.2.25→4.5, nix 0.26→0.29, byteorder 1.3→1.5, num 0.2→0.4
- Normalize serde version constraints from '>=1.0' to '1.0'
- Add comprehensive package metadata to all Cargo.toml files:
  - Add missing authors, descriptions, and license information
  - Fix repository URLs pointing to correct GitHub organization
  - Add relevant keywords and categories for Rust package discovery
  - Set homepage links to main repository
- Establish workspace-level metadata inheritance
- Add accessibility improvements to README.md banner image
- Set rust-version metadata to 1.80 for toolchain consistency

This improves package discoverability, maintainability, and follows Rust ecosystem best practices.
Replaced panicking unwrap/expect calls with proper error handling.
Now gives cleaner error messages when config file is missing or invalid,
and when command execution fails. Exit codes are preserved.
Replaced println statements with tracing for better observability.
All proxy binaries now support RUST_LOG env var for log level control.

Changes:
- Added tracing and tracing-subscriber dependencies
- Converted all println/eprintln to structured logging (info/error/warn)
- Logs include contextual info like addresses, directions, and error details
- Default log level is info, configurable via RUST_LOG env var

This aligns with the roadmap item for improved logging in proxies.
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.

1 participant