Skip to main content

Async logging system with local caching and syncing system

Project description

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

pip install zira

Important Note:

To streamline your code, you can specify the Mongo URI in a .env file as the variable ZIRALOG_MONGO:

# .env
ZIRALOG_MONGO='mongodb://user:pass@host:port/'

Alternatively, you can provide the Mongo URI directly when creating a ZiraLog or Sync instance:

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

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.

from zira.sync import Sync

zira_sync = Sync(db_name="test_zira_log", sync_interval=3600) #run every hour
await zira_sync.start_sync()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zira-1.0.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zira-1.0.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file zira-1.0.1.tar.gz.

File metadata

  • Download URL: zira-1.0.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for zira-1.0.1.tar.gz
Algorithm Hash digest
SHA256 eccc398c5377a35303c2da6ec269f38ae31f39dd6ca8e1d821703ffe70ee8cd9
MD5 90be6bd1e31de080906ccb2ea3caf5fc
BLAKE2b-256 604548248d365babfa9ce9dba50e331eb78275804152cb21133a6e044c2c2d7f

See more details on using hashes here.

File details

Details for the file zira-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: zira-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for zira-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5ea8ad3e6e95f67713d96fc6f8e6db170db9228526e698862d8fca7facdf203
MD5 480c8cf091c840333c7666ca9d55b9e5
BLAKE2b-256 23939e01691a68901007d1c99a7ad5fa0323d1f600a924f0219311e94a958726

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page