# TradATA Core
Professional core framework designed for trading and market data applications.
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
[](https://badge.fury.io/py/tradata-logger)
## Features
- 🚀 **FastAPI Middleware** - Automatic request logging with trace IDs
- 📊 **Structured JSON Logging** - Consistent, searchable log format
- 🔗 **Request Correlation** - Track requests across microservices
- ⚡ **High Performance** - Async-first design with minimal overhead
- 🎯 **Trading-Specific** - Specialized logging for financial applications
- 🔧 **Easy Configuration** - Environment variables and programmatic setup
- 🎭 **Context Management** - Automatic operation and step tracking
- 🏷️ **Decorators** - One-liner logging for API endpoints
## Quick Start
### Installation
**This is a private package accessible only to your GitHub organization.**
#### **Option 1: Automated Setup (Recommended)**
```bash
# Download and run the setup script
curl -O https://raw.githubusercontent.com/your-org/tradata-core-py/main/setup_private_install.sh
chmod +x setup_private_install.sh
./setup_private_install.sh YOUR_GITHUB_TOKEN_HERE
```
#### **Option 2: Manual Installation**
```bash
# Install from private GitHub Packages
pip install tradata-core-py
# Or install directly from private repository
pip install git+https://YOUR_TOKEN@github.com/your-org/tradata-core-py.git
```
**See [Private Package Setup Guide](PRIVATE_PACKAGE_README.md) for detailed instructions.**
### Basic Usage
```python
from tradata_core import get_logger
logger = get_logger("my-service")
await logger.info("Service started", "Service", "Startup")
```
### FastAPI Integration
```python
from fastapi import FastAPI
from tradata_core import LoggingMiddleware
app = FastAPI()
app.add_middleware(LoggingMiddleware)
# Automatic request logging with trace IDs!
```
## Why TradATA Logger?
### For Trading Applications
- **Operation Tracking**: Log business operations (e.g., "QuoteRetrieval", "TradeExecution")
- **Step Monitoring**: Track specific steps within operations (e.g., "Validation", "API_Call")
- **Performance Metrics**: Built-in timing and performance logging
- **Cache Operations**: Specialized logging for cache hits/misses
- **Client Tracking**: Monitor external API usage and performance
### For Microservices
- **Trace ID Propagation**: Follow requests across service boundaries
- **Request Correlation**: Link related operations with unique identifiers
- **Structured Logging**: Consistent JSON format for log aggregation
- **Middleware Integration**: Framework-specific middleware for automatic logging
### For Development Teams
- **Clean APIs**: Decorators and context managers for minimal code
- **Comprehensive Coverage**: Automatic logging of requests, errors, and performance
- **Flexible Configuration**: Environment-based and programmatic configuration
- **Extensible Design**: Easy to add custom formatters and handlers
## Core Concepts
### Operation and Step Tracking
Every log entry includes:
- **Operation**: High-level business operation (e.g., "QuoteRetrieval")
- **Step**: Specific step within the operation (e.g., "API_Call", "Validation")
```python
await logger.info("Quote retrieved", "QuoteRetrieval", "API_Call", symbol="AAPL")
```
### Context Variables
Automatic tracking of:
- **Trace ID**: Unique identifier for request chains
- **Request ID**: Unique identifier for individual requests
- **Client**: External service being used
### Structured Logging
All logs include structured data for easy searching and analysis:
```json
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "INFO",
"message": "Quote retrieved successfully",
"operation": "QuoteRetrieval",
"step": "API_Call",
"trace_id": "trace_12345",
"request_id": "req_67890",
"client": "alpaca_api",
"symbol": "AAPL",
"duration_ms": 150.5
}
```
## Usage Examples
### Basic Logging
```python
from tradata_core import get_logger
logger = get_logger("quotes-service")
# Basic logging
await logger.info("Processing started", "DataProcessing", "Validation")
await logger.error("API call failed", "ExternalAPI", "Call", error="Connection timeout")
# Specialized logging
await logger.log_cache_operation("Cache_Get", True, "quote:AAPL", 5.0)
await logger.log_client_operation("API_Call", "alpaca_api", "get_quote", 150.0)
```
### API Endpoint Logging
```python
from tradata_logger.utils.decorators import log_endpoint
@app.get("/quotes/{symbol}")
@log_endpoint("/quotes/{symbol}", "quote_retrieval", "quotes_service")
async def get_quote(symbol: str):
# Automatic logging of request, processing, and response
return {"symbol": symbol, "price": 150.00}
```
### Context Management
```python
from tradata_logger.utils.context import logging_context
async with logging_context("data_processing", "batch_validation") as ctx:
ctx.add_context(batch_size=1000, dataset="market_data")
for item in data:
# Process item
pass
# Automatic completion logging with duration
```
### FastAPI Middleware
```python
from tradata_core import LoggingMiddleware, PerformanceLoggingMiddleware
app = FastAPI()
# Basic logging middleware
app.add_middleware(LoggingMiddleware)
# Performance-focused middleware
app.add_middleware(PerformanceLoggingMiddleware)
```
## Configuration
### Environment Variables
```bash
LOG_LEVEL=INFO
LOG_FORMAT=json
LOG_INCLUDE_TRACE_ID=true
LOG_PERFORMANCE=true
LOG_CACHE_OPERATIONS=true
```
### Programmatic Configuration
```python
from tradata_logger.config import LogConfig, HandlerConfig
config = LogConfig(
level="DEBUG",
format="console",
handlers=[
HandlerConfig(type="console", level="DEBUG"),
HandlerConfig(type="file", filename="app.log", level="INFO")
]
)
```
## Installation
### From PyPI
```bash
pip install tradata-logger
```
### From Source
```bash
git clone https://github.com/tradata/tradata-logger-py.git
cd tradata-logger-py
pip install -e .
```
### Development Dependencies
```bash
pip install -e ".[dev]"
```
## Testing
```bash
# Run all tests
pytest
# Run with coverage
pytest --cov=tradata_logger
# Run specific test file
pytest tests/test_logger.py
```
## Examples
See the `examples/` directory for complete working examples:
- `basic_usage.py` - Basic logger usage
- `fastapi_example.py` - FastAPI integration
- `flask_example.py` - Flask integration (placeholder)
## Documentation
Comprehensive documentation is available in the `docs/` directory:
- [API Reference](docs/API.md)
- [Examples](docs/examples.md)
- [Configuration Guide](docs/README.md)
## Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
### Development Setup
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Run the test suite
6. Submit a pull request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- **GitHub Issues**: [Report bugs or request features](https://github.com/tradata/tradata-logger-py/issues)
- **Documentation**: [Comprehensive guides and examples](https://github.com/tradata/tradata-logger-py/tree/main/docs)
- **Examples**: [Working code examples](https://github.com/tradata/tradata-logger-py/tree/main/examples)
## Roadmap
- [ ] Flask middleware implementation
- [ ] Additional log formatters
- [ ] Cloud logging integrations
- [ ] Performance dashboard
- [ ] Log aggregation tools
- [ ] More specialized logging methods
## Acknowledgments
- Built for the trading and financial technology community
- Inspired by modern logging practices and observability needs
- Designed with microservices and distributed systems in mind
---
**TradATA Logger** - Professional logging for professional applications.
Raw data
{
"_id": null,
"home_page": null,
"name": "tradata-core-py",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "TradATA Team <team@tradata.com>",
"keywords": "core, logging, trading, fastapi, middleware, observability, framework",
"author": null,
"author_email": "TradATA Team <team@tradata.com>",
"download_url": "https://files.pythonhosted.org/packages/c2/b8/d7c122555d9ad58e42c042df78f2af2d1f2e416445574b9b9b41afedde60/tradata_core_py-0.1.0.tar.gz",
"platform": null,
"description": "# TradATA Core\n\nProfessional core framework designed for trading and market data applications.\n\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n[](https://badge.fury.io/py/tradata-logger)\n\n## Features\n\n- \ud83d\ude80 **FastAPI Middleware** - Automatic request logging with trace IDs\n- \ud83d\udcca **Structured JSON Logging** - Consistent, searchable log format\n- \ud83d\udd17 **Request Correlation** - Track requests across microservices\n- \u26a1 **High Performance** - Async-first design with minimal overhead\n- \ud83c\udfaf **Trading-Specific** - Specialized logging for financial applications\n- \ud83d\udd27 **Easy Configuration** - Environment variables and programmatic setup\n- \ud83c\udfad **Context Management** - Automatic operation and step tracking\n- \ud83c\udff7\ufe0f **Decorators** - One-liner logging for API endpoints\n\n## Quick Start\n\n### Installation\n\n**This is a private package accessible only to your GitHub organization.**\n\n#### **Option 1: Automated Setup (Recommended)**\n```bash\n# Download and run the setup script\ncurl -O https://raw.githubusercontent.com/your-org/tradata-core-py/main/setup_private_install.sh\nchmod +x setup_private_install.sh\n./setup_private_install.sh YOUR_GITHUB_TOKEN_HERE\n```\n\n#### **Option 2: Manual Installation**\n```bash\n# Install from private GitHub Packages\npip install tradata-core-py\n\n# Or install directly from private repository\npip install git+https://YOUR_TOKEN@github.com/your-org/tradata-core-py.git\n```\n\n**See [Private Package Setup Guide](PRIVATE_PACKAGE_README.md) for detailed instructions.**\n\n### Basic Usage\n\n```python\nfrom tradata_core import get_logger\n\nlogger = get_logger(\"my-service\")\nawait logger.info(\"Service started\", \"Service\", \"Startup\")\n```\n\n### FastAPI Integration\n\n```python\nfrom fastapi import FastAPI\nfrom tradata_core import LoggingMiddleware\n\napp = FastAPI()\napp.add_middleware(LoggingMiddleware)\n\n# Automatic request logging with trace IDs!\n```\n\n## Why TradATA Logger?\n\n### For Trading Applications\n\n- **Operation Tracking**: Log business operations (e.g., \"QuoteRetrieval\", \"TradeExecution\")\n- **Step Monitoring**: Track specific steps within operations (e.g., \"Validation\", \"API_Call\")\n- **Performance Metrics**: Built-in timing and performance logging\n- **Cache Operations**: Specialized logging for cache hits/misses\n- **Client Tracking**: Monitor external API usage and performance\n\n### For Microservices\n\n- **Trace ID Propagation**: Follow requests across service boundaries\n- **Request Correlation**: Link related operations with unique identifiers\n- **Structured Logging**: Consistent JSON format for log aggregation\n- **Middleware Integration**: Framework-specific middleware for automatic logging\n\n### For Development Teams\n\n- **Clean APIs**: Decorators and context managers for minimal code\n- **Comprehensive Coverage**: Automatic logging of requests, errors, and performance\n- **Flexible Configuration**: Environment-based and programmatic configuration\n- **Extensible Design**: Easy to add custom formatters and handlers\n\n## Core Concepts\n\n### Operation and Step Tracking\n\nEvery log entry includes:\n- **Operation**: High-level business operation (e.g., \"QuoteRetrieval\")\n- **Step**: Specific step within the operation (e.g., \"API_Call\", \"Validation\")\n\n```python\nawait logger.info(\"Quote retrieved\", \"QuoteRetrieval\", \"API_Call\", symbol=\"AAPL\")\n```\n\n### Context Variables\n\nAutomatic tracking of:\n- **Trace ID**: Unique identifier for request chains\n- **Request ID**: Unique identifier for individual requests\n- **Client**: External service being used\n\n### Structured Logging\n\nAll logs include structured data for easy searching and analysis:\n\n```json\n{\n \"timestamp\": \"2024-01-15T10:30:00Z\",\n \"level\": \"INFO\",\n \"message\": \"Quote retrieved successfully\",\n \"operation\": \"QuoteRetrieval\",\n \"step\": \"API_Call\",\n \"trace_id\": \"trace_12345\",\n \"request_id\": \"req_67890\",\n \"client\": \"alpaca_api\",\n \"symbol\": \"AAPL\",\n \"duration_ms\": 150.5\n}\n```\n\n## Usage Examples\n\n### Basic Logging\n\n```python\nfrom tradata_core import get_logger\n\nlogger = get_logger(\"quotes-service\")\n\n# Basic logging\nawait logger.info(\"Processing started\", \"DataProcessing\", \"Validation\")\nawait logger.error(\"API call failed\", \"ExternalAPI\", \"Call\", error=\"Connection timeout\")\n\n# Specialized logging\nawait logger.log_cache_operation(\"Cache_Get\", True, \"quote:AAPL\", 5.0)\nawait logger.log_client_operation(\"API_Call\", \"alpaca_api\", \"get_quote\", 150.0)\n```\n\n### API Endpoint Logging\n\n```python\nfrom tradata_logger.utils.decorators import log_endpoint\n\n@app.get(\"/quotes/{symbol}\")\n@log_endpoint(\"/quotes/{symbol}\", \"quote_retrieval\", \"quotes_service\")\nasync def get_quote(symbol: str):\n # Automatic logging of request, processing, and response\n return {\"symbol\": symbol, \"price\": 150.00}\n```\n\n### Context Management\n\n```python\nfrom tradata_logger.utils.context import logging_context\n\nasync with logging_context(\"data_processing\", \"batch_validation\") as ctx:\n ctx.add_context(batch_size=1000, dataset=\"market_data\")\n \n for item in data:\n # Process item\n pass\n \n # Automatic completion logging with duration\n```\n\n### FastAPI Middleware\n\n```python\nfrom tradata_core import LoggingMiddleware, PerformanceLoggingMiddleware\n\napp = FastAPI()\n\n# Basic logging middleware\napp.add_middleware(LoggingMiddleware)\n\n# Performance-focused middleware\napp.add_middleware(PerformanceLoggingMiddleware)\n```\n\n## Configuration\n\n### Environment Variables\n\n```bash\nLOG_LEVEL=INFO\nLOG_FORMAT=json\nLOG_INCLUDE_TRACE_ID=true\nLOG_PERFORMANCE=true\nLOG_CACHE_OPERATIONS=true\n```\n\n### Programmatic Configuration\n\n```python\nfrom tradata_logger.config import LogConfig, HandlerConfig\n\nconfig = LogConfig(\n level=\"DEBUG\",\n format=\"console\",\n handlers=[\n HandlerConfig(type=\"console\", level=\"DEBUG\"),\n HandlerConfig(type=\"file\", filename=\"app.log\", level=\"INFO\")\n ]\n)\n```\n\n## Installation\n\n### From PyPI\n\n```bash\npip install tradata-logger\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/tradata/tradata-logger-py.git\ncd tradata-logger-py\npip install -e .\n```\n\n### Development Dependencies\n\n```bash\npip install -e \".[dev]\"\n```\n\n## Testing\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=tradata_logger\n\n# Run specific test file\npytest tests/test_logger.py\n```\n\n## Examples\n\nSee the `examples/` directory for complete working examples:\n\n- `basic_usage.py` - Basic logger usage\n- `fastapi_example.py` - FastAPI integration\n- `flask_example.py` - Flask integration (placeholder)\n\n## Documentation\n\nComprehensive documentation is available in the `docs/` directory:\n\n- [API Reference](docs/API.md)\n- [Examples](docs/examples.md)\n- [Configuration Guide](docs/README.md)\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n### Development Setup\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests\n5. Run the test suite\n6. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- **GitHub Issues**: [Report bugs or request features](https://github.com/tradata/tradata-logger-py/issues)\n- **Documentation**: [Comprehensive guides and examples](https://github.com/tradata/tradata-logger-py/tree/main/docs)\n- **Examples**: [Working code examples](https://github.com/tradata/tradata-logger-py/tree/main/examples)\n\n## Roadmap\n\n- [ ] Flask middleware implementation\n- [ ] Additional log formatters\n- [ ] Cloud logging integrations\n- [ ] Performance dashboard\n- [ ] Log aggregation tools\n- [ ] More specialized logging methods\n\n## Acknowledgments\n\n- Built for the trading and financial technology community\n- Inspired by modern logging practices and observability needs\n- Designed with microservices and distributed systems in mind\n\n---\n\n**TradATA Logger** - Professional logging for professional applications.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Professional core framework for trading applications",
"version": "0.1.0",
"project_urls": {
"Changelog": "https://github.com/TradataTech/tradata-core-py/blob/main/CHANGELOG.md",
"Discussions": "https://github.com/TradataTech/tradata-core-py/discussions",
"Documentation": "https://github.com/TradataTech/tradata-core-py/tree/main/docs",
"Homepage": "https://github.com/TradataTech/tradata-core-py",
"Issues": "https://github.com/TradataTech/tradata-core-py/issues",
"Repository": "https://github.com/TradataTech/tradata-core-py"
},
"split_keywords": [
"core",
" logging",
" trading",
" fastapi",
" middleware",
" observability",
" framework"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "37a35574ffd4c4db4ead6d886e897531c293faef3f65b1cd09e9ffa552a97f50",
"md5": "1b8dde12b653a9066d26016c384ab929",
"sha256": "4eb1dab5369e4ce669e6d0c02d3ab98b30e1feb2f7bf98a7aa503d1afa1f0121"
},
"downloads": -1,
"filename": "tradata_core_py-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b8dde12b653a9066d26016c384ab929",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 24072,
"upload_time": "2025-08-22T02:48:38",
"upload_time_iso_8601": "2025-08-22T02:48:38.435828Z",
"url": "https://files.pythonhosted.org/packages/37/a3/5574ffd4c4db4ead6d886e897531c293faef3f65b1cd09e9ffa552a97f50/tradata_core_py-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c2b8d7c122555d9ad58e42c042df78f2af2d1f2e416445574b9b9b41afedde60",
"md5": "d854a6fe09de1c2fdac8adc86f1a0a19",
"sha256": "116ad6e99bb477d9322432e5ce25979776ddf404c3bdab46c73a218788b4e21b"
},
"downloads": -1,
"filename": "tradata_core_py-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "d854a6fe09de1c2fdac8adc86f1a0a19",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 25220,
"upload_time": "2025-08-22T02:48:39",
"upload_time_iso_8601": "2025-08-22T02:48:39.988437Z",
"url": "https://files.pythonhosted.org/packages/c2/b8/d7c122555d9ad58e42c042df78f2af2d1f2e416445574b9b9b41afedde60/tradata_core_py-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-22 02:48:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TradataTech",
"github_project": "tradata-core-py",
"github_not_found": true,
"lcname": "tradata-core-py"
}