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

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_logger_alert-0.1.9.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.9.tar.gz
Algorithm Hash digest
SHA256 55af150f4dcf0b21259fa0331beb41ec6d031da57bbd0acf086ff8445b412034
MD5 024e6050184eef4480325351d823611c
BLAKE2b-256 6dc7dc705589886563f1c9d73d8e3973e7333f267c5561de94cd243660f38693

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_logger_alert-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 807d3c372608d97560c55064c3ba2a79e9a9547da9b60a820f6293142f101ba0
MD5 983fea9735186d2a9de57b52b2f559df
BLAKE2b-256 4dc259fb398458e4d19e20c7d7b2c14d0d216e2e7bdf6a9207470fefb3e524d7

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