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.2.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.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zira-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e42a76a1ca3060b50e4bb23220e0704c410421c980e23acb1c8cc2fcc8d12ef5
MD5 c8026114efee05404e2e4f1baeb07909
BLAKE2b-256 673ce4dafaf2bd63a78df79ba71d3c2e078c7faea91d53d87f11f4f765477b16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zira-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a987d9b40b5bc577583cd50aca9ec421ac43487efb05d536ae1e4d51ba108af
MD5 500b01085d2f0c2b0465d559de913cd8
BLAKE2b-256 a72a232f9ec74b967ffe6e04084b2466f0b4b5c1814a16c46235c53cb1eb7879

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