Skip to content

feat: add structured logging with tracing, JSON format, and file rota…#86

Merged
Nanle-code merged 4 commits intoNanle-code:masterfrom
Manuelshub:feat/structured-logging
Apr 29, 2026
Merged

feat: add structured logging with tracing, JSON format, and file rota…#86
Nanle-code merged 4 commits intoNanle-code:masterfrom
Manuelshub:feat/structured-logging

Conversation

@Manuelshub
Copy link
Copy Markdown
Contributor

Closes #38

Summary

Basic println! statements provided no structured output, no log levels, and no way to configure verbosity or format for CI/CD pipelines. This PR introduces a structured logging subsystem using the tracing ecosystem, with support for multiple log levels, human and JSON output formats, and optional file rotation.

Changes

New: src/utils/logging.rs

  • LogFormat enum — Human (default) or Json
  • LogConfig struct — configures level, format, and optional log directory
  • init(config: LogConfig) — initialises the global tracing subscriber; supports all four combinations of format × file/stderr
  • config_from_env() — builds LogConfig from CLI flags
  • File rotation via tracing-appender::rolling::daily when a log directory is provided
  • RUST_LOG environment variable overrides the configured log level

src/main.rs

  • Added --log-format <human|json> global CLI flag
  • Added --log-dir <path> global CLI flag for file rotation
  • logging::init() called at startup before any command runs

Cargo.toml

  • Added tracing = "0.1"
  • Added tracing-subscriber = { version = "0.3", features = ["env-filter", "json", "fmt"] }
  • Added tracing-appender = "0.2"

src/utils/mod.rs

  • Registered pub mod logging

Usage

# Default human-readable output (warnings and above)
starforge wallet list

# Debug level via RUST_LOG
RUST_LOG=debug starforge deploy --wasm contract.wasm

# JSON output for CI/CD log aggregators
starforge --log-format json wallet create alice

# Write rotating daily log files to a directory
starforge --log-dir ~/.starforge/logs wallet show alice

# JSON + file rotation combined
starforge --log-format json --log-dir /var/log/starforge tx history GABC...

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@Manuelshub Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Manuelshub
Copy link
Copy Markdown
Contributor Author

@Nanle-code Please review

@Nanle-code
Copy link
Copy Markdown
Owner

@Manuelshub resolve conflict

@Manuelshub
Copy link
Copy Markdown
Contributor Author

@Nanle-code Please review

@Nanle-code Nanle-code merged commit e003009 into Nanle-code:master Apr 29, 2026
1 check passed
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.

Implement Structured Logging and Debug Framework

2 participants