# Zira: Enhanced Event Tracking for Logging in Python
Zira designed to help developers efficiently track and understand the root cause of various events. It supports logging directly to MongoDB and offers local storage fallback if database connectivity is interrupted. Zira then syncs logs automatically once the database connection is restored, ensuring no data is lost.
## Installation
```bash
pip install zira
```
## Important Note:
To streamline your code, you can specify the `Mongo URI` in a `.env` file as the variable `ZIRALOG_MONGO`:
```python
# .env
ZIRALOG_MONGO='mongodb://user:pass@host:port/'
```
Alternatively, you can provide the Mongo URI directly when creating a `ZiraLog` or `Sync` instance:
```python
log_db_uri='mongodb://user:pass@host:port/'
zira = ZiraLog(mongoURI=log_db_uri, service_name="TestService", db_name="test_zira_log")
```
## Use Case Example
### Logging
```python
import asyncio
from zira.logger import ZiraLog
async def main():
zira = ZiraLog(service_name="TestService", db_name="test_zira_log")
log_tasks = []
log_tasks.append(zira.started(message="Test 1"))
log_tasks.append(zira.warning(message="Test 2"))
log_tasks.append(zira.error(message="Test 3"))
log_tasks.append(zira.finished(message="Test 4"))
await asyncio.gather(*log_tasks)
if __name__ == "__main__":
asyncio.run(main())
```
### Syncing
If database connectivity is interrupted, use the `Sync` class to periodically sync stored logs with MongoDB.
```python
from zira.sync import Sync
zira_sync = Sync(db_name="test_zira_log", sync_interval=3600) #run every hour
await zira_sync.start_sync()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ShayanSadeghi/zira",
"name": "zira",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "log, event-logger, logger, monitor",
"author": "Shayan Sadeghi",
"author_email": "ShayanSadeghi1996@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/bf/13/c55d67d2c783882027d531e685e9a93fbd131258ad55a91b1bd6f5aed7db/zira-1.0.3.tar.gz",
"platform": null,
"description": "# Zira: Enhanced Event Tracking for Logging in Python\n\nZira designed to help developers efficiently track and understand the root cause of various events. It supports logging directly to MongoDB and offers local storage fallback if database connectivity is interrupted. Zira then syncs logs automatically once the database connection is restored, ensuring no data is lost.\n\n## Installation\n\n```bash\npip install zira\n```\n\n## Important Note:\nTo streamline your code, you can specify the `Mongo URI` in a `.env` file as the variable `ZIRALOG_MONGO`:\n\n```python\n# .env\nZIRALOG_MONGO='mongodb://user:pass@host:port/'\n\n```\n\nAlternatively, you can provide the Mongo URI directly when creating a `ZiraLog` or `Sync` instance:\n\n\n```python\n\nlog_db_uri='mongodb://user:pass@host:port/'\n\nzira = ZiraLog(mongoURI=log_db_uri, service_name=\"TestService\", db_name=\"test_zira_log\")\n\n```\n\n\n## Use Case Example\n\n\n### Logging\n\n```python\nimport asyncio\n\nfrom zira.logger import ZiraLog \n\nasync def main():\n zira = ZiraLog(service_name=\"TestService\", db_name=\"test_zira_log\")\n\n log_tasks = []\n log_tasks.append(zira.started(message=\"Test 1\"))\n log_tasks.append(zira.warning(message=\"Test 2\"))\n log_tasks.append(zira.error(message=\"Test 3\"))\n log_tasks.append(zira.finished(message=\"Test 4\"))\n\n await asyncio.gather(*log_tasks)\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n```\n\n\n### Syncing\n\nIf database connectivity is interrupted, use the `Sync` class to periodically sync stored logs with MongoDB.\n\n```python\nfrom zira.sync import Sync\n\nzira_sync = Sync(db_name=\"test_zira_log\", sync_interval=3600) #run every hour\nawait zira_sync.start_sync()\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Async logging system with local caching and syncing system",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/ShayanSadeghi/zira"
},
"split_keywords": [
"log",
" event-logger",
" logger",
" monitor"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "83fa8547c38e4571f1e229bfae515c014a05a95deed386d74d65f4bd66b704de",
"md5": "af0c9f7f39c33e1e8557d3b11c6cbb15",
"sha256": "741cef234baf31c05311eaee349e1b80a6ee70373107dd17901eeda940d22e0d"
},
"downloads": -1,
"filename": "zira-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af0c9f7f39c33e1e8557d3b11c6cbb15",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 8192,
"upload_time": "2024-11-13T12:31:10",
"upload_time_iso_8601": "2024-11-13T12:31:10.260993Z",
"url": "https://files.pythonhosted.org/packages/83/fa/8547c38e4571f1e229bfae515c014a05a95deed386d74d65f4bd66b704de/zira-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bf13c55d67d2c783882027d531e685e9a93fbd131258ad55a91b1bd6f5aed7db",
"md5": "22a775e9a6f2a581de50152c02eae520",
"sha256": "aecb6cd299013458017d0f7ebd6886ad3551b5cb2fc62be84a992bb38ac27512"
},
"downloads": -1,
"filename": "zira-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "22a775e9a6f2a581de50152c02eae520",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7637,
"upload_time": "2024-11-13T12:31:15",
"upload_time_iso_8601": "2024-11-13T12:31:15.082338Z",
"url": "https://files.pythonhosted.org/packages/bf/13/c55d67d2c783882027d531e685e9a93fbd131258ad55a91b1bd6f5aed7db/zira-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-13 12:31:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ShayanSadeghi",
"github_project": "zira",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "zira"
}