Skip to main content

Simplifies sending logs from your bots to DB.

Project description

aiogram-logger


Simplifies sending logs from your bots to DB.

example

Quick start with InfluxDB + Grafana

Install package from pip

pip install aiogram_logging

Prepare InlfuxDB and Grafana with this repo.

Import and create instances

from aiogram_logging import Logger, InfluxSender

sender = InfluxSender(host='localhost',
                      db='db-name',
                      username='db-user',
                      password='db-password')
logger = Logger(sender)

Create StatMiddleware to logging every incoming message

class StatMiddleware(BaseMiddleware):

    def __init__(self):
        super(StatMiddleware, self).__init__()

    async def on_process_message(self, message: types.Message, data: dict):
        await logger.write_logs(self._manager.bot.id, message, parse_text=True)


dp.middleware.setup(StatMiddleware())

Create dashboard by yourself or import from grafana-dashboard.json

Yeah, you can connect several bots for one InfluxDB

TODO:

  1. Explain how to manage logs from several bots in Grafana
  2. Parse more different data

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

aiogram-logging-0.0.1.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

aiogram_logging-0.0.1-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

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