# CrashSense Best Practices

## 1. Use Python's logging module, not print()
- Always use `logging.getLogger(__name__)` for module-level loggers.
- Configure logging early in your application.

## 2. Structure logs for context
- Include user IDs, request IDs, timestamps, and error codes.
- Use structured logging for easier debugging.

## 3. Error handling
- Use try/except blocks and log exceptions with `logger.exception()`.
- Provide clear, actionable error messages.
- Fail fast and guide users through errors gracefully.

## 4. Log rotation and retention
- Use `RotatingFileHandler` or `TimedRotatingFileHandler` to manage log size.
- Keep backup logs and avoid disk space issues.

## 5. Avoid logging sensitive data
- Mask or redact passwords, API keys, and personal data.

## 6. Centralize logging configuration
- Use a single config file for logging across modules.
- Prefer JSON/YAML config for flexibility.

## 7. Test your logging
- Write unit tests to ensure logs are generated as expected.

## 8. CLI crash analysis
- Provide clear CLI commands for analyzing logs and reporting actionable fixes.
- Summarize crash context and remediation steps for users.

---
This file was generated by CrashSense using best practices and web search knowledge (2025).
