Skip to main content

Um monitor de logs automático via Telegram para robôs Python

Project description

py-logger-alert 🚀

Uma biblioteca leve e eficiente para monitoramento de scripts e bots em Python.

O py-logger-alert integra o sistema de logging padrão do Python com o Telegram, permitindo receber alertas de erros críticos em tempo real, enquanto mantém um histórico completo de logs em arquivos locais.

Ideal para quem roda bots, automações, robôs de trading ou scripts agendados e precisa saber imediatamente quando algo dá errado.


✨ Principais Funcionalidades

  • 📢 Notificações em Tempo Real
    Envia logs de nível ERROR e CRITICAL diretamente para o Telegram.

  • ⚙️ Configuração Simplificada
    Suporte nativo a variáveis de ambiente via arquivo .env.

  • 🧾 Formatação Amigável
    Mensagens formatadas em blocos de código, facilitando leitura de tracebacks.

  • 🔐 Segurança
    Truncamento automático de mensagens longas para respeitar os limites da API do Telegram.


🛠 Instalação

pip install py-logger-alert

⚙️ Configuração do Telegram

🤖 Criando o Bot (BotFather)

  1. Abra o Telegram e procure por @BotFather
  2. Envie o comando:
/start
  1. Crie o bot:
/newbot
  1. Defina o nome e o username (termina com bot)
  2. Copie o TOKEN retornado

🆔 Obtendo o Chat ID

  1. Procure por @userinfobot
  2. Envie:
/start
  1. Copie o número retornado (Chat ID)

📁 Arquivo .env

TELEGRAM_TOKEN=seu_token_aqui
TELEGRAM_CHAT_ID=seu_chat_id_aqui

🚀 Como Usar

from py_logger_alert import setup_monitoring
import logging

setup_monitoring(
    nome_robo="Robô Trader v1",
    log_filename="logs_bot"
)

logging.info("Sistema iniciado com sucesso.")

try:
    10 / 0
except Exception as e:
    logging.error(f"Erro crítico detectado: {e}", exc_info=True)

📜 Licença

MIT License


👨‍💻 Autor

Vitor Marinheiro
https://github.com/vitormarinheiro1
https://github.com/vitormarinheiro1/py-logger-alert

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

py_logger_alert-0.1.7.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

py_logger_alert-0.1.7-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file py_logger_alert-0.1.7.tar.gz.

File metadata

  • Download URL: py_logger_alert-0.1.7.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for py_logger_alert-0.1.7.tar.gz
Algorithm Hash digest
SHA256 fdd91d194faa370eb5ec7534bf06c84570e64afd956158e88e51092ceb5bc520
MD5 a96fa237fa6211698fccfb4e0338e1de
BLAKE2b-256 161537ab20a2dcd742c2834558fb894a26fe7d5e3d6ad48a5180451b11cd1f22

See more details on using hashes here.

File details

Details for the file py_logger_alert-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for py_logger_alert-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 0c55f7f75daa5704f5790a9c29db2ac0e7ba6f6fe8badf58a2ec598c352a60b4
MD5 dc750491ecea26d7d3fc85be328d33a5
BLAKE2b-256 5403b5153d11b44a07e52d926816dfeb7550ca004390d7a225dea73b19c377d7

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