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.

  • 🗂 Registro Local Automático
    Salva logs (INFO, WARNING, ERROR, etc.) em arquivos .log.

  • ⚙️ 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

Crie um arquivo .env na raiz do projeto:

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)

📖 Função Principal

setup_monitoring(nome_robo, log_filename)

Configura o ambiente global de logging da aplicação.


📜 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.4.tar.gz (3.1 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.4-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_logger_alert-0.1.4.tar.gz
  • Upload date:
  • Size: 3.1 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.4.tar.gz
Algorithm Hash digest
SHA256 e6524f828fc70d4d81e5e75c3268e58e8d8705567f0c3defbdf17e80960e0d52
MD5 e63b35d70d5d4ed6a61e5f3bd811b85e
BLAKE2b-256 8341eb4f48ff6cfcdef813d9d05ae3b07dc4575c2cc8b468d10db984cd8a1abb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_logger_alert-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d34077bd2d6656cc80a6758662d8d81ee84fca84a4c5d6898c49e8411a0be18d
MD5 53ab14350098fd37a05d1e96b7229977
BLAKE2b-256 4856de109c4edad330c317d8e94495364ea922d00278ba6e3b1a0123487c55ca

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