Skip to main content

Library for logging runtime errors and sending execution reports via Telegram and Email

Project description

runreporter

Библиотека для логирования ошибок и отправки отчетов по завершению выполнения.

Возможности:

  • Логирование в файл
  • Сбор последних 300 строк лога в отчет
  • Отправка отчетов в Telegram (по chat_id)
  • Отправка отчетов на Email (SMTP)
  • Флаги: отправлять ли отчеты при отсутствии ошибок; приоритетный канал (Telegram/Email)

Установка

pip install runreporter

Пример использования

from runreporter import ErrorManager, SmtpConfig

manager = ErrorManager(
    log_file_path="app.log",
    telegram_bot_token="123:ABC",
    telegram_chat_ids=[11111111, 22222222],
    smtp_config=SmtpConfig(
        host="smtp.example.com",
        port=465,
        username="user@example.com",
        password="pass",
        use_ssl=True,
        from_addr="user@example.com",
    ),
    email_recipients=["dev1@example.com", "dev2@example.com"],
    send_reports_without_errors=False,
    primary_channel="telegram",  # "telegram" или "email"
)

with manager.context(run_name="Ежедневный импорт") as log:
    log.info("Начало работы")
    # ваш код
    log.error("Ошибка обработки записи id=42")

Конфигурация

  • send_reports_without_errors: если False, отчеты будут отправляться только при наличии ошибок
  • primary_channel: "telegram" или "email" — приоритет канала; второй используется как резервный

Лицензия

MIT

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

runreporter-0.1.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

runreporter-0.1.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file runreporter-0.1.3.tar.gz.

File metadata

  • Download URL: runreporter-0.1.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for runreporter-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6839176f364bada4e9017f90e13b66a9905dcf9111c208baa62b90da715cc053
MD5 289cb3335dd571b4118d30aeefd34a78
BLAKE2b-256 c34c3bad60df6a3e0d28b6799c66fdf4160253a995b2f360629a0c322251b0cf

See more details on using hashes here.

File details

Details for the file runreporter-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: runreporter-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for runreporter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7572839c6d6d5ac8c6ef30fe73c7a10f172ddd9dcaca430e334404efbbede943
MD5 32e6acabccf684ac9fbeb2c729f2de70
BLAKE2b-256 c43a5f46746fa2441c00d3df36a122af14467ee9bfb4a50ed5eb6f31a13fde1a

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