Skip to content

dkeysil/aiogram-logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simplifies the implementation of logs for your bots.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages