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

Uploaded Python 3

File details

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

File metadata

  • Download URL: zira-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 193b2e3c5c257e22debcce5bcc24a004c43fc0845426f1b75aab9aa6aeca882e
MD5 c683b2a8f5302f531a8442b5f00258b1
BLAKE2b-256 36c1343279d15393f7a298890543c00f17463a9eecb0e0f578338e828badcf67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zira-1.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 92ea52b90252e4a0b262c07681a20ed62953e66618a1cd89c1c35efe4b039bc1
MD5 23fac5c5eff50f669656d6186f49d287
BLAKE2b-256 a025260a2f0f0e2a41f170c82859041153e1aa9529111521f423a92e37688042

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