Built-in Utilities
The tools/ package provides production-ready utility modules that you can use in your projects. These modules handle common tasks like logging, configuration management, and performance monitoring.
Overview
The built-in utilities are designed to:
- Reduce boilerplate - Common patterns already implemented
- Follow best practices - Production-tested patterns
- Support multiple environments - Local development and cloud deployment
- Type-safe - Full type hints for better IDE support
Available Modules
Logger - Flexible Logging System
A custom logger that supports both local development and cloud environments.
Key features:
- Colored console output for local development
- Structured JSON logging for Google Cloud
- Easy to switch between modes
- Built on Python's standard logging module
Quick example:
1 2 3 4 5 | |
Configuration - Environment Management
Pydantic-based configuration that loads settings from environment variables and .env files.
Key features:
- Type-safe configuration
- Automatic
.envfile loading - FastAPI integration
- Environment detection (local vs production)
Quick example:
1 2 3 4 5 | |
→ Full Configuration documentation
Tracer - Performance Monitoring
Timer decorator and context manager for measuring code execution time.
Key features:
- Works as decorator or context manager
- Automatic logging of execution time
- Millisecond precision
- No manual time tracking needed
Quick example:
1 2 3 4 5 6 7 8 9 10 | |
Module Architecture
Package Structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Import Patterns
The package is designed for convenient imports:
1 2 3 4 5 6 7 | |
Common Use Cases
FastAPI Application
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Data Processing Pipeline
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Microservice with Configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Customization
All modules are designed to be extended. You can:
- Subclass
Settingsto add your own configuration fields - Create custom formatters for the Logger
- Build on the Timer to add custom metrics
See the individual module documentation for examples.
Testing
All utilities include comprehensive tests. See tests/tools/ for examples:
test__logger.py- Logger teststest__config.py- Configuration teststest__tracer.py- Timer tests
Run tests with:
1 | |
Next Steps
- Explore each module in detail:
- Logger documentation
- Configuration documentation
- Tracer documentation
- See real-world examples in Use Cases
- Check the source code in
tools/for implementation details