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 @@LogsRobosBot
  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.8.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.8-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_logger_alert-0.1.8.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.8.tar.gz
Algorithm Hash digest
SHA256 3cd2edcd709b889aa15351b88b8766b24571b0c94967911621251d2b331ae139
MD5 350f3a5ce2efeb0453e69adbaa064181
BLAKE2b-256 aabc0d13879263b80231e87c1b702199555624c521f0c4697904e85221706dc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_logger_alert-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 141ccfbc2ff3dfa7caa508c3918bf284a3a0f82bed637246637b768e6c9cec26
MD5 216c845f738c9467ed3fb74c16c9e326
BLAKE2b-256 35baa55dff697a00a502349cc7972fb4572a6b3ef0b1317cf05daca22327907e

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