/logze

Library in Python to store logs in MongoDB and send notifications of errors to Teams

Primary LanguagePythonMIT LicenseMIT

LOGZE

PyPI version fury.io Downloads Bandit Percentage of issues still open MIT License

Library in Python to store logs in MongoDB and send notifications of errors to MS Teams.

Install

Install logze using PyPI or directly via pip:

  pip install logze

Usage

from logze.recorder.logger import LogRecorder
from logze.models.log import Log


recorder = LogRecorder("{YOUR_CONN_STRING}", "{DB_NAME}", "{COLLECTION_NAME}", "{MS_TEAMS_WEBHOOK}")

log = Log("{SOURCE}", "{LOG_TYPE}", "{MESSAGE}", "{EVENT}")
recorder.record_log(log)

Running unit tests

$ export MONGO_URI="mongodb://user:password@host:port/?authMechanism=DEFAULT"
$ export DB_NAME="YOUR_DB_NAME"
$ python -m unittest discover tests
...
------------------------------------------------------------------------------
Ran 3 tests in 0.144s

OK

Author