Skip to main content

Envie logs e alertas para o Telegram em 60s (Python)

Project description

telelog-py

Envie logs e alertas para o Telegram em 60 segundos (Python).

Instalação

pip install telelog-py

Uso mínimo

from telelog import send_telegram
send_telegram("job concluído ✅")

Logging

import logging
from telelog import TelegramLogHandler

log = logging.getLogger("myapp")
log.setLevel(logging.INFO)
log.addHandler(TelegramLogHandler())
log.error("falhou", exc_info=True)

Variáveis de ambiente

  • TELEGRAM_BOT_TOKEN
  • TELEGRAM_CHAT_ID ou TELEGRAM_CHAT_IDS (separados por vírgula)
  • TELEGRAM_PARSE_MODE (opcional: MarkdownV2 ou HTML; padrão: texto puro)

CLI

telelog "mensagem"

Códigos de saída:

  • 0: sucesso
  • 1: falha de envio
  • 2: uso incorreto ou configuração ausente

Comportamento

  • Truncamento em 4096 caracteres com sufixo ....
  • Retries (3), timeout (5s), backoff exponencial base 500ms com jitter ±20%.
  • 429: respeita retry_after do Telegram.
  • MarkdownV2/HTML: escape automático quando TELEGRAM_PARSE_MODE definido.

Segurança

Nunca commitar .env. Use .env.example como referência e secrets no CI/CD.

Requisitos

  • Python >= 3.8

Variáveis de ambiente e .env

  • A biblioteca lê um arquivo .env do diretório atual (CWD), se existir.
  • Variáveis já definidas no ambiente têm precedência e não são sobrescritas pelo .env.
  • Necessárias:
    • TELEGRAM_BOT_TOKEN
    • TELEGRAM_CHAT_ID ou TELEGRAM_CHAT_IDS (múltiplos separados por vírgula)

Autor & Contato

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

telelog_py-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

telelog_py-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file telelog_py-0.1.1.tar.gz.

File metadata

  • Download URL: telelog_py-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for telelog_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 175c38884d436ac07d867772fcbd7b722eeb9502773948603c8c4db0d6457305
MD5 d4a36136f154f287fcf74a768f054478
BLAKE2b-256 7e95e431b8b86bd5bbcb98392843434a2d9a27e42b93c6aa1e3f5c75579348fc

See more details on using hashes here.

File details

Details for the file telelog_py-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: telelog_py-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for telelog_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7b438598cc09af5ba91acf10d0a913b051715ef9b777143ba866e6494e63e8d
MD5 c2739ed2426967e352c0064df57bbfb5
BLAKE2b-256 b19340a2b4a4b8bbc7df8395085e3c0ec05c8ccd74e0b535110f343d31582261

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