tsutils includes a local error logging system designed for open-source CLI tools. This system helps users and maintainers diagnose issues while respecting user privacy.
- Local-only: All error logs are stored locally on your machine
- Privacy-focused: Sanitizes error messages to remove sensitive data
- Enabled by default: Can be easily disabled via environment variable
- No external services: No data is sent to external servers or tracking services
- Transparent: Clear documentation of what is logged
If you prefer not to have errors logged locally, you can disable error logging:
# Disable for a single command
TSU_ERROR_LOG=false tsu git changed
# Disable globally in your shell profile
export TSU_ERROR_LOG=falseBy default, error logs are stored in ~/.tsu/logs/. You can customize this location:
# Use a custom directory
export TSU_LOG_DIR=/path/to/custom/logsWhen an error occurs, the following information is recorded in ~/.tsu/logs/errors.log:
- Timestamp: When the error occurred
- Version: The version of tsutils you're running
- Node Version: Your Node.js version
- Platform: Your operating system (linux, darwin, win32, etc.)
- Command: The command that was executed
- Working Directory: Your current working directory (with
~replacing home directory) - Error Message: The error message (sanitized)
- Stack Trace: The error stack trace (sanitized, if available)
The error logger automatically sanitizes logged data to protect your privacy:
- Paths: Your home directory is replaced with
~to prevent leaking your username - Secrets: Patterns that look like API keys, tokens, or passwords are redacted as
[REDACTED] - No network data: No information is sent over the network
Error logs are stored at:
~/.tsu/logs/errors.log
You can find your exact log file location by running:
echo ~/.tsu/logs/errors.logEach error entry in the log file looks like this:
---
Timestamp: 2025-12-28T16:00:00.000Z
Version: 0.15.0
Node: v20.19.5
Platform: linux
Command: tsu git changed
CWD: ~/projects/my-app
Error: git command failed: not a git repository
Stack:
Error: git command failed: not a git repository
at gitCheck (~/projects/tsu/dist/commands/git/check.js:10:15)
at Command.action (~/projects/tsu/dist/cli.js:83:5)
To view recent errors:
# View the entire log file
cat ~/.tsu/logs/errors.log
# View the last 50 lines
tail -n 50 ~/.tsu/logs/errors.log
# View errors from today
grep "$(date +%Y-%m-%d)" ~/.tsu/logs/errors.logIf you want to clear your error logs:
# Clear all logs
rm ~/.tsu/logs/errors.log
# Or clear the entire logs directory
rm -rf ~/.tsu/logs/If you encounter a bug or error:
- Check existing issues: Visit GitHub Issues to see if it's already reported
- Gather information: Review your error log at
~/.tsu/logs/errors.log - Create an issue: If it's a new issue, open a GitHub issue with:
- The command you ran
- The error message
- Relevant parts of your error log (sanitized automatically)
- Your environment (from the log: version, node version, platform)
When reporting an issue, include the relevant error log entry. The log is already sanitized, but you should still review it to ensure no sensitive information is included:
# Get the last error entry
tail -n 15 ~/.tsu/logs/errors.logPlease review the log entry and remove any additional sensitive information before sharing.
-
Check if it's disabled:
echo $TSU_ERROR_LOG
If this prints "false", error logging is disabled.
-
Check directory permissions:
ls -la ~/.tsu/Ensure you have write permissions to the directory.
-
Try with a custom directory:
mkdir -p /tmp/tsu-logs TSU_LOG_DIR=/tmp/tsu-logs tsu git changed ls /tmp/tsu-logs/
Error logs are appended to the same file. If the log file becomes too large:
# Check log file size
du -h ~/.tsu/logs/errors.log
# Archive old logs
mv ~/.tsu/logs/errors.log ~/.tsu/logs/errors-$(date +%Y%m%d).log
# Or simply delete
rm ~/.tsu/logs/errors.logIf you're contributing to tsutils and want to add error logging to new commands:
import { logError } from '../utils/error-logger.js';
try {
// Your command logic
} catch (error) {
// Log the error for diagnostics
logError(error, 'tsu command-name');
// Display user-friendly error message
console.error('Error: Something went wrong');
process.exit(1);
}See CONTRIBUTING.md for more details on adding error logging to commands.
- User credentials or tokens
- API keys or secrets
- Full file contents
- Network requests or responses
- Personal identifiable information (PII)
- Command-line arguments (already visible in your shell history)
- Error messages (sanitized)
- File paths (with home directory replaced by
~) - System information (Node version, platform)
For an open-source CLI tool, local logging provides several benefits:
- User Control: You control your data and can delete logs anytime
- Privacy: No data leaves your machine
- Transparency: You can inspect logs to see exactly what's recorded
- No dependencies: No external services or API keys required
- Works offline: Logging works without internet connection
Unlike cloud-based error tracking services (like Datadog, Sentry, etc.):
- ✅ No account required: No sign-up or registration
- ✅ No data sharing: Your error data stays on your machine
- ✅ No costs: Completely free, no usage limits
- ✅ No tracking: No user tracking or analytics
- ✅ Works offline: No internet connection needed
- ❌ Manual reporting: You need to manually share logs when reporting issues
- ❌ No aggregation: Can't see patterns across multiple users
- ❌ No real-time alerting: Maintainers aren't notified of errors
For an open-source CLI tool, the privacy and simplicity benefits outweigh the limitations of local-only logging.
- SECURITY.md - Security policy and practices
- CONTRIBUTING.md - Contributing guidelines
- GitHub Issues - Report bugs and issues