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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: zira-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 b504fc1a10ddcdad3b6863966ff5cb700c6e1027fcbc60ee22c08ec3cea8047c
MD5 e890b955b8e3b37396b0f947b8409bb2
BLAKE2b-256 ea2f73dce78289f63bfd9216f3d0729484f21e51bf7f5b7809ee0d66cbadb212

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zira-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 711286d667843659213c95d07632924e9b41ece49bf9db746cf1c16f096fbd5b
MD5 f4c13e91612a103638b2df08449350ab
BLAKE2b-256 bb940412789ec73d7a75f3474a57810e0f6a631731ffa2559abc8d57282c2bf7

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