# 🌈 Tamga
A beautiful and customizable logger for Python web applications. Tamga provides colorful console output and organized log files for different types of logs.
![Python](https://img.shields.io/badge/python-v3.10+-blue.svg)
![License](https://img.shields.io/badge/license-MIT-green.svg)
![Version](https://img.shields.io/badge/version-0.1.0-blue.svg)
## ✨ Features
- 🎨 Beautiful colored console output
- 📁 Separate log files for different types of logs (danger, success, warning, info, app, SQL)
- 🕒 Timestamp and timezone information for each log
- 🔄 Automatic log rotation with backup files
- 🔒 Thread-safe logging for concurrent applications
- 🚀 High-performance buffered writing
- ⚙️ Highly customizable configuration
- 🎯 Easy to use API
## 📦 Installation
```bash
pip install tamga
```
## 🚀 Quick Start
```python
from tamga import Log
# Initialize logger with default configuration
logger = Log()
# Log different types of messages
logger.info("Server started on port 8000")
logger.success("Database connection established")
logger.warning("High memory usage detected")
logger.danger("Failed to connect to database")
logger.app("Application initialized")
logger.sql("SELECT * FROM users")
# Print a breaker line
logger.breaker()
```
## 🛠️ Custom Configuration
```python
from tamga import Log
from tamga.config import Config
# Create custom configuration
config = Config(
app_name="MyApp",
app_version="1.0.0",
log_dir="logs",
max_file_size=10 * 1024 * 1024, # 10MB
backup_count=5,
date_format="%Y-%m-%d",
time_format="%H:%M:%S",
enable_colors=True
)
# Initialize logger with custom config
logger = Log(config)
```
## 🌟 Log Types
- `info()`: For general information messages
- `success()`: For successful operations
- `warning()`: For warning messages
- `danger()`: For error messages
- `app()`: For application-specific messages
- `sql()`: For SQL queries
- `breaker()`: Prints a separator line
## 🔥 Advanced Features
### Context Manager Support
```python
with Log() as logger:
logger.info("Using logger in a with statement")
logger.success("This will auto-close when done")
```
### Thread Safety
```python
# Safe to use in multi-threaded applications
from threading import Thread
def worker():
logger.info("Worker thread started")
threads = [Thread(target=worker) for _ in range(5)]
for t in threads:
t.start()
```
### Log Rotation
```python
config = Config(
max_file_size=5 * 1024 * 1024, # 5MB
backup_count=3 # Keep 3 backup files
)
logger = Log(config)
```
## 🌐 Web Framework Integration
### Flask Example
```python
from flask import Flask
from tamga import Log
app = Flask(__name__)
logger = Log()
@app.route('/')
def home():
logger.info("Home endpoint accessed")
return "Hello, World!"
@app.errorhandler(Exception)
def handle_error(error):
logger.danger(f"Error occurred: {str(error)}")
return "Internal Server Error", 500
```
### FastAPI Example
```python
from fastapi import FastAPI
from tamga import Log
app = FastAPI()
logger = Log()
@app.get('/')
async def home():
logger.info("Home endpoint accessed")
return {"message": "Hello, World!"}
@app.exception_handler(Exception)
async def exception_handler(request, exc):
logger.danger(f"Error occurred: {str(exc)}")
return {"error": "Internal Server Error"}
```
## 📝 Example Output
Console output will look like this (with colors):
```
MyApp@1.0.0 [2024-01-14 | 15:30:45.123 | UTC] INFO Server started on port 8000
MyApp@1.0.0 [2024-01-14 | 15:30:45.124 | UTC] SUCCESS Database connection established
MyApp@1.0.0 [2024-01-14 | 15:30:45.125 | UTC] WARNING High memory usage detected
```
## 🤝 Contributing
Contributions are welcome! Here's how you can help:
1. Fork the repository
2. Create a new branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Commit your changes (`git commit -m 'Add amazing feature'`)
5. Push to the branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 🙏 Credits
Created and maintained by [Dogukan Urker](https://github.com/dogukanurker)
## 📂 Examples
Complete example applications can be found in the `examples` directory:
- `basic_usage.py`: Demonstrates all logger features and configurations
- `flask_app.py`: Shows how to integrate the logger with a Flask application
To run the examples:
```bash
# Basic usage example
python examples/basic_usage.py
# Flask application example
pip install flask # Install Flask first
python examples/flask_app.py
```
Raw data
{
"_id": null,
"home_page": "https://github.com/dogukanurker/tamga",
"name": "tamga",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "logging logger colorful web flask fastapi",
"author": "Dogukan Urker",
"author_email": "dogukanurker@icloud.com",
"download_url": "https://files.pythonhosted.org/packages/06/c1/dd2aabba9118ecffa1d4afdb862e39ee5de596db84ceb960ff6d36c9292a/tamga-0.1.1.tar.gz",
"platform": null,
"description": "# \ud83c\udf08 Tamga\n\nA beautiful and customizable logger for Python web applications. Tamga provides colorful console output and organized log files for different types of logs.\n\n![Python](https://img.shields.io/badge/python-v3.10+-blue.svg)\n![License](https://img.shields.io/badge/license-MIT-green.svg)\n![Version](https://img.shields.io/badge/version-0.1.0-blue.svg)\n\n## \u2728 Features\n\n- \ud83c\udfa8 Beautiful colored console output\n- \ud83d\udcc1 Separate log files for different types of logs (danger, success, warning, info, app, SQL)\n- \ud83d\udd52 Timestamp and timezone information for each log\n- \ud83d\udd04 Automatic log rotation with backup files\n- \ud83d\udd12 Thread-safe logging for concurrent applications\n- \ud83d\ude80 High-performance buffered writing\n- \u2699\ufe0f Highly customizable configuration\n- \ud83c\udfaf Easy to use API\n\n## \ud83d\udce6 Installation\n\n```bash\npip install tamga\n```\n\n## \ud83d\ude80 Quick Start\n\n```python\nfrom tamga import Log\n\n# Initialize logger with default configuration\nlogger = Log()\n\n# Log different types of messages\nlogger.info(\"Server started on port 8000\")\nlogger.success(\"Database connection established\")\nlogger.warning(\"High memory usage detected\")\nlogger.danger(\"Failed to connect to database\")\nlogger.app(\"Application initialized\")\nlogger.sql(\"SELECT * FROM users\")\n\n# Print a breaker line\nlogger.breaker()\n```\n\n## \ud83d\udee0\ufe0f Custom Configuration\n\n```python\nfrom tamga import Log\nfrom tamga.config import Config\n\n# Create custom configuration\nconfig = Config(\n app_name=\"MyApp\",\n app_version=\"1.0.0\",\n log_dir=\"logs\",\n max_file_size=10 * 1024 * 1024, # 10MB\n backup_count=5,\n date_format=\"%Y-%m-%d\",\n time_format=\"%H:%M:%S\",\n enable_colors=True\n)\n\n# Initialize logger with custom config\nlogger = Log(config)\n```\n\n## \ud83c\udf1f Log Types\n\n- `info()`: For general information messages\n- `success()`: For successful operations\n- `warning()`: For warning messages\n- `danger()`: For error messages\n- `app()`: For application-specific messages\n- `sql()`: For SQL queries\n- `breaker()`: Prints a separator line\n\n## \ud83d\udd25 Advanced Features\n\n### Context Manager Support\n```python\nwith Log() as logger:\n logger.info(\"Using logger in a with statement\")\n logger.success(\"This will auto-close when done\")\n```\n\n### Thread Safety\n```python\n# Safe to use in multi-threaded applications\nfrom threading import Thread\n\ndef worker():\n logger.info(\"Worker thread started\")\n \nthreads = [Thread(target=worker) for _ in range(5)]\nfor t in threads:\n t.start()\n```\n\n### Log Rotation\n```python\nconfig = Config(\n max_file_size=5 * 1024 * 1024, # 5MB\n backup_count=3 # Keep 3 backup files\n)\nlogger = Log(config)\n```\n\n## \ud83c\udf10 Web Framework Integration\n\n### Flask Example\n```python\nfrom flask import Flask\nfrom tamga import Log\n\napp = Flask(__name__)\nlogger = Log()\n\n@app.route('/')\ndef home():\n logger.info(\"Home endpoint accessed\")\n return \"Hello, World!\"\n\n@app.errorhandler(Exception)\ndef handle_error(error):\n logger.danger(f\"Error occurred: {str(error)}\")\n return \"Internal Server Error\", 500\n```\n\n### FastAPI Example\n```python\nfrom fastapi import FastAPI\nfrom tamga import Log\n\napp = FastAPI()\nlogger = Log()\n\n@app.get('/')\nasync def home():\n logger.info(\"Home endpoint accessed\")\n return {\"message\": \"Hello, World!\"}\n\n@app.exception_handler(Exception)\nasync def exception_handler(request, exc):\n logger.danger(f\"Error occurred: {str(exc)}\")\n return {\"error\": \"Internal Server Error\"}\n```\n\n## \ud83d\udcdd Example Output\n\nConsole output will look like this (with colors):\n```\nMyApp@1.0.0 [2024-01-14 | 15:30:45.123 | UTC] INFO Server started on port 8000\nMyApp@1.0.0 [2024-01-14 | 15:30:45.124 | UTC] SUCCESS Database connection established\nMyApp@1.0.0 [2024-01-14 | 15:30:45.125 | UTC] WARNING High memory usage detected\n```\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Here's how you can help:\n\n1. Fork the repository\n2. Create a new branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Commit your changes (`git commit -m 'Add amazing feature'`)\n5. Push to the branch (`git push origin feature/amazing-feature`)\n6. Open a Pull Request\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Credits\n\nCreated and maintained by [Dogukan Urker](https://github.com/dogukanurker) \n\n## \ud83d\udcc2 Examples\n\nComplete example applications can be found in the `examples` directory:\n\n- `basic_usage.py`: Demonstrates all logger features and configurations\n- `flask_app.py`: Shows how to integrate the logger with a Flask application\n\nTo run the examples:\n\n```bash\n# Basic usage example\npython examples/basic_usage.py\n\n# Flask application example\npip install flask # Install Flask first\npython examples/flask_app.py\n``` \n",
"bugtrack_url": null,
"license": null,
"summary": "A beautiful and customizable logger for Python web applications",
"version": "0.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/dogukanurker/tamga/issues",
"Documentation": "https://github.com/dogukanurker/tamga#readme",
"Homepage": "https://github.com/dogukanurker/tamga",
"Source Code": "https://github.com/dogukanurker/tamga"
},
"split_keywords": [
"logging",
"logger",
"colorful",
"web",
"flask",
"fastapi"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "612593eabb7ce0d57a8fa05b64400ab7423603d1eadbb8cea4885ea0b7cfadb9",
"md5": "53da83bcd2e5473523a29e5e1f0f2b6d",
"sha256": "25b7444da1c2941f2207cdf530b4f7b5c7c50936d388628f7d228355b2364a8d"
},
"downloads": -1,
"filename": "tamga-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "53da83bcd2e5473523a29e5e1f0f2b6d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 8411,
"upload_time": "2025-01-14T15:56:13",
"upload_time_iso_8601": "2025-01-14T15:56:13.255671Z",
"url": "https://files.pythonhosted.org/packages/61/25/93eabb7ce0d57a8fa05b64400ab7423603d1eadbb8cea4885ea0b7cfadb9/tamga-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "06c1dd2aabba9118ecffa1d4afdb862e39ee5de596db84ceb960ff6d36c9292a",
"md5": "861fb0f68f82c4d05e87a7e0b042b424",
"sha256": "3c25d795469c8d881ce00036f8fe007ef0397766bb4bbeac367c8eeec40b37de"
},
"downloads": -1,
"filename": "tamga-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "861fb0f68f82c4d05e87a7e0b042b424",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 9761,
"upload_time": "2025-01-14T15:56:16",
"upload_time_iso_8601": "2025-01-14T15:56:16.642731Z",
"url": "https://files.pythonhosted.org/packages/06/c1/dd2aabba9118ecffa1d4afdb862e39ee5de596db84ceb960ff6d36c9292a/tamga-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-14 15:56:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dogukanurker",
"github_project": "tamga",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "pytz",
"specs": [
[
">=",
"2024.1"
]
]
}
],
"lcname": "tamga"
}