mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
3.6 KiB
3.6 KiB
Terminal Logging Style Guide
This guide defines the terminal output style for all bash scripts in the Spine Runtimes project.
Design Principles
- Minimal visual noise - Use color sparingly for emphasis, not decoration
- Clear hierarchy - Different levels of information have distinct visual treatments
- Consistent spacing - Clean vertical rhythm throughout output
- Accessible - Readable and meaningful even without colors
- Scannable - Easy to quickly identify successes, failures, and important information
Visual Hierarchy
1. Title (log_title)
- Purpose: Main script/tool name
- Style: Bold with vertical spacing
- Usage: Once at the beginning of script execution
log_title "Spine-C++ Test"
2. Section (log_section)
- Purpose: Major phases or groups of operations
- Style: Bold blue text, no extra spacing
- Usage: Build, Test, Deploy, etc.
log_section "Build"
log_section "Test"
3. Action (log_action)
- Purpose: Individual operations in progress
- Style: Indented, followed by "..."
- Usage: Before starting an operation
log_action "Building all variants"
log_action "Testing headless-test"
4. Results
- Purpose: Outcome of operations
- Style: Indented with colored symbols
log_ok "Build completed" # Green ✓
log_fail "Build failed" # Red ✗
log_warn "Deprecated feature" # Yellow !
log_skip "Not supported on macOS" # Gray -
5. Detail (log_detail)
- Purpose: Secondary information, error output, debug info
- Style: Gray text, indented
- Usage: Additional context, error messages
log_detail "Platform: Darwin"
log_detail "$ERROR_OUTPUT"
6. Summary (log_summary)
- Purpose: Final result or conclusion
- Style: Bold with vertical spacing
- Usage: End of script execution
log_summary "✓ All tests passed (5/5)"
log_summary "✗ Tests failed (3/5)"
Complete Example
#!/bin/bash
source ../formatters/bash-colors.sh
log_title "Spine-C++ Test"
log_detail "Platform: $(uname)"
log_section "Build"
log_action "Building all variants"
if BUILD_OUTPUT=$(./build.sh clean release 2>&1); then
log_ok "Build completed"
else
log_fail "Build failed"
log_detail "$BUILD_OUTPUT"
exit 1
fi
log_section "Test"
log_action "Testing headless-test"
if test_result; then
log_ok "headless-test"
else
log_fail "headless-test - execution failed"
log_detail "$error_output"
fi
log_summary "✓ All tests passed (2/2)"
Output Preview
Spine-C++ Test
Platform: Darwin
Build
Building all variants...
✓ Build completed
Test
Testing headless-test...
✓ headless-test
Testing headless-test-nostdcpp...
✓ headless-test-nostdcpp
✓ All tests passed (2/2)
Error Handling Best Practices
- Capture output: Use
OUTPUT=$(command 2>&1)to capture both stdout and stderr - Check exit codes: Always check if critical operations succeeded
- Show details on failure: Use
log_detailto show error output - Fail fast: Exit immediately on critical failures
- Clear error messages: Make failure reasons obvious
if BUILD_OUTPUT=$(./build.sh clean release 2>&1); then
log_ok "Build completed"
else
log_fail "Build failed"
log_detail "$BUILD_OUTPUT"
exit 1
fi
Usage
- Source the utilities in your script:
source ../formatters/logging/bash-colors.sh
- Follow the hierarchy patterns shown above
- Use appropriate functions for each type of output
- Test output both with and without color support