# πͺΆ saydbg
[](https://crates.io/crates/saydbg)
[](https://docs.rs/saydbg)
[](./LICENSE)
A **tiny, dependency-light macro crate** for conditional debug printing β designed to give you
`println!`-style logging in debug builds, with optional color and timestamps.
In release mode, all debug macros are **completely compiled out** (zero cost).
---
## β¨ Features
β
Simple `println!`-style usage
β
Works only in debug mode (`cfg(debug_assertions)`)
β
Optional **colored** output (`--features color`)
β
Optional **timestamps** (`--features timestamp`)
β
Zero-cost in release builds
β
MIT licensed β free for any project
---
## π¦ Installation
Add to your projectβs `Cargo.toml`:
```toml
[dependencies]
saydbg = "0.1"
```
Optionally enable features:
```toml
[dependencies]
saydbg = { version = "0.1", features = ["color", "timestamp"] }
```
---
## π§ Example
```rust
use saydbg::{saydbg, saywarn, sayerr, saytrace, saylog};
fn main() {
saydbg!("Connected to database");
saywarn!("Missing optional config file");
saytrace!("Query took {:?} ms", 5);
sayerr!("User not found: {}", "admin");
saylog!("Server started successfully");
}
```
### π§± Default Output (Debug build)
```
[debug] Connected to database
[warn] Missing optional config file
[trace] Query took 5 ms
[error] User not found: admin
[log] Server started successfully
```
### π With `--features color`
Colors (blue, yellow, red, gray, green) are added for easy scanning.
### π With `--features timestamp`
```
[2025-10-08 12:11:47] [debug] Connected to database
[2025-10-08 12:11:47] [warn] Missing optional config file
```
---
## βοΈ Macros
| `saydbg!` | General debug info | Blue | `stdout` | Debug only |
| `sayerr!` | Errors | Red | `stderr` | Debug only |
| `saywarn!` | Warnings | Yellow | `stdout` | Debug only |
| `saytrace!` | Verbose trace info | Gray | `stdout` | Debug only |
| `saylog!` | Always-on log (even in release) | Green | `stdout` | All builds |
---
## π Why use `saydbg`?
Because sometimes you donβt need a full logger β just some conditional, colorful debug messages that disappear in release builds.
`saydbg` sits between:
- βοΈ `println!()` β simple but always prints
- π§± `log` or `tracing` β powerful but heavy for small tools
Perfect for:
- CLI utilities
- Tauri or WASM apps
- Embedded debugging
- Classroom or educational projects
- Quick prototypes or experiments
---
## π§ Feature Flags
| `color` | Enables colored log labels via [`colored`](https://crates.io/crates/colored) | β |
| `timestamp` | Adds local timestamps using [`chrono`](https://crates.io/crates/chrono) | β |
Enable both for maximum clarity:
```toml
[dependencies]
saydbg = { version = "0.1", features = ["color", "timestamp"] }
```
---
## π§© Example Project Integration
```rust
use saydbg::{saydbg, saywarn, sayerr};
pub fn connect_db() {
saydbg!("Connecting to database...");
// ...
saywarn!("Connection is slow, retrying...");
sayerr!("Database unreachable after retries");
}
```
All of these compile away completely in release:
```bash
cargo run --release
# (no debug output at all)
```
---
## π License
Licensed under the [MIT License](./LICENSE).
---
## π‘ Author
**Ryon Boswell** β [@crookedlungs](https://github.com/crookedlungs)
A developer and educator creating lightweight, modular tools for Rust and education.
---
## π Contributing
Pull requests, feature ideas, and improvements are welcome.
You can clone this repo, modify the macros, or submit suggestions on [GitHub](https://github.com/crookedlungs/saydbg).
---
> π¦ *"Debug smart, release clean."* β `saydbg`