deep_log
A dual-axis logging system for Rust — level (verbosity) + zone (bitflag per system).
Two orthogonal axes, two independent outputs: console and file.
Concept
A message is displayed/written if:
its_level <= log_level (verbosity threshold)
AND
its_zone ∈ active_zones (system filter)
log_level |
Effect |
|---|---|
0 |
Nothing is logged |
10 |
Messages with level <= 10 (normal info) |
50 |
Messages with level <= 50 (details) |
100 |
Everything |
Installation
[]
= "0.3.0"
Quick start
use ;
Console output — set()
use LogZone;
set; // normal info
set; // everything
set; // nothing
set_all; // equivalent to set(100, LogZone::ALL)
set_none; // equivalent to set(0, LogZone::ALL)
File output — log_to_file()
use LogZone;
// One file per zone, in the given directory (absolute or relative)
log_to_file;
// → logs/BASIC_2026-03-23_14-30-00.log
// → logs/PHYSICS_2026-03-23_14-30-00.log
Behaviour:
- New file on every call (datetime in filename — no overwriting)
- Flush on every line (safe for crash debugging)
- One file per zone
- Directory created automatically if it doesn't exist
- Files closed automatically on program exit (drop)
Console and file are independent
// Show only normal info on console
set;
// Log everything to file, different zone
log_to_file;
// This goes to file only (PHYSICS not in console zones)
dlog!;
// This goes to console only (RENDER not in file zones)
dlog!;
Predefined zones
| Zone | Bit | Intended use |
|---|---|---|
BASIC |
1 << 0 |
Init, startup, configuration |
RENDER |
1 << 1 |
Pipeline, draw calls, frames |
MATRIX |
1 << 2 |
Matrices, NDC, camera |
SHADER |
1 << 3 |
Uniforms, bindings, shaders |
CHUNK |
1 << 4 |
Meshing, voxels, world generation |
PHYSICS |
1 << 5 |
Collisions, raycasts |
AUDIO |
1 << 6 |
Audio, sounds |
NET |
1 << 7 |
Network, serialization |
ALL |
u32::MAX |
All zones |
NONE |
0 |
No zone |
Custom zones
Use bits 8→31 to avoid collisions with predefined zones:
use LogZone;
const AI: LogZone = custom;
const PATHFIND: LogZone = custom;
set;
log_to_file;
dlog!;
Suggested levels
| Level | Usage |
|---|---|
10 |
Normal info (startup, GPU name...) |
20 |
Render stats |
50 |
Matrices, NDC validation |
70 |
Meshing, chunk data |
100 |
Frame-by-frame verbose |
Thread safety
All configuration uses AtomicU8 and AtomicU32. File writes are protected by a Mutex.
Zero allocation on the hot path (console only). File writes allocate a formatted string per message.
No external dependencies
current_datetime() is implemented using only std::time::SystemTime — no chrono, no time.
License
MIT OR Apache-2.0