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.5.tar.gz (3.2 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.5-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_logger_alert-0.1.5.tar.gz
  • Upload date:
  • Size: 3.2 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.5.tar.gz
Algorithm Hash digest
SHA256 01a2a818bd7ada858a0ad9be4212a318946a20e78211ac45d9ba215b8502a285
MD5 639a651ff532a191e7389c69ad0743ce
BLAKE2b-256 5b8507d4ed38d9b6bf51786734b5e0b0017c03b76a6d7c447931599e5e98547b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_logger_alert-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 16b8756755a956c7d6466a6229ac2d780f09a8e80100e5b1a70ba84854216e7b
MD5 5cb41065bbb0b6b6f315ecf1802f3e99
BLAKE2b-256 aa2978c258b75ffb3c2dbe62e77fd8b8ed586f02aa500a80cb3e2ae374b8cdad

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