773 . ** Choose appropriate levels** : error for failures, debug for detailed flow
884 . ** Include context** : What operation, which file/module, relevant values
995 . ** NEVER log in hot paths** : No logs inside tight loops
10+ 6 . ** Use test macros in test code** : ` test_debug! ` , ` test_info! ` , ` test_error! ` , ` test_warn! `
1011
1112## Log Level Guidelines
1213
1516- ` info! ` : High-level operations (1-2 per command max)
1617- ` debug! ` : Detailed flow (Git commands, transformations, RON dumps - everything)
1718
19+ ### Test Code Logging
20+
21+ - ` test_error! ` : Test failures and setup errors
22+ - ` test_warn! ` : Test warnings (slow operations, skipped tests)
23+ - ` test_info! ` : Test progress and important milestones
24+ - ` test_debug! ` : Detailed test flow and intermediate results
25+
1826## Usage
1927
2028``` bash
@@ -36,10 +44,21 @@ RUST_LOG=trace zerv version
3644
3745# Test debugging
3846RUST_LOG=debug cargo test test_name
47+
48+ # Test-only logs (using custom macros)
49+ RUST_LOG=zerv_test=info cargo test test_name
50+
51+ # Test logs + specific source modules
52+ RUST_LOG=zerv_test=info,zerv::cli::flow=debug cargo test test_name
53+
54+ # Show all logs (test + source)
55+ RUST_LOG=debug cargo test test_name
3956```
4057
4158## Examples
4259
60+ ### Source Code Logging
61+
4362``` rust
4463// ✅ GOOD - Appropriate level and context
4564tracing :: debug! (" Loading schema: {}" , schema_name );
@@ -51,3 +70,46 @@ tracing::info!("Calling function xyz"); // Too verbose for info
5170// ❌ BAD - Missing context
5271tracing :: error! (" Parse failed" ); // What failed? Where? Why?
5372```
73+
74+ ### Test Code Logging
75+
76+ ``` rust
77+ use crate :: test_utils :: logging :: {test_debug, test_info, test_error, test_warn};
78+
79+ #[test]
80+ fn test_version_generation () {
81+ test_debug! (" Starting test: version generation" );
82+
83+ let fixture = GitRepoFixture :: tagged (" v1.0.0" )
84+ . expect (" Failed to create test fixture" );
85+ test_info! (" Created test fixture at: {}" , fixture . path (). display ());
86+
87+ let result = run_pipeline (& fixture );
88+ if let Err (e ) = result {
89+ test_error! (" Pipeline failed: {}" , e );
90+ return ;
91+ }
92+
93+ test_debug! (" Test completed successfully" );
94+ }
95+
96+ // ✅ GOOD - Test-specific logging with context
97+ test_debug! (" Flow pipeline output ({}): {}" , format_name , output );
98+ test_info! (" Test setup completed for branch: {}" , branch_name );
99+
100+ // ❌ BAD - Using source code logging in tests
101+ tracing :: debug! (" Test message" ); // Mixes with source code logs
102+ ```
103+
104+ ### Test Log Filtering Examples
105+
106+ ``` bash
107+ # Show only test logs (no source code noise)
108+ RUST_LOG=zerv_test=debug cargo test
109+
110+ # Show test info + source debug
111+ RUST_LOG=zerv_test=info,zerv::vcs=debug cargo test
112+
113+ # Show all logs when debugging
114+ RUST_LOG=debug cargo test
115+ ```
0 commit comments