Skip to main content

🦜 A CLI tool to monitor a file and send updates to Telegram.

Project description

log2telegram

log2telegram is a CLI tool to monitor changes in a specified log file and send updates to a Telegram chat. This package allows you to stay informed about updates in critical logs or other files by sending new content as Telegram messages, with customizable options to filter color codes and timestamps.

Features

•	Real-Time Monitoring: Continuously watches for changes in a log file, sending new content as Telegram messages.
•	Configurable Delay: Set a custom interval for checking the file for changes.
•	Filtering Options: Remove ANSI color codes and timestamps at the start of lines for cleaner messages.
•	Customizable Message Splitting: Automatically splits messages if they exceed the Telegram message size limit.
•	Error Handling and Logging: Logs errors if the file is unreadable, ensuring smooth operation and easy debugging.

Installation

You can install the package via PyPI:

pip install log2telegram

Setup

To use log2telegram, add the following environment variables to a .env file:

LOG2TELEGRAM_BOT_TOKEN= LOG2TELEGRAM_CHAT_ID=

•	LOG2TELEGRAM_BOT_TOKEN: Your Telegram bot token, obtained from BotFather.
•	LOG2TELEGRAM_CHAT_ID: The chat ID where messages will be sent.

Usage

Run the log2telegram command to monitor a file for changes. You can specify the path to the file and set optional flags for filtering.

Command-Line Arguments

log2telegram [--seconds_delay SECONDS] [--filter-color-chars] [--filter-timestamps]

•	<file-path> (required): The path to the file to monitor.
•	--seconds_delay (optional): Interval in seconds between each check (default: 1). Must be a positive integer.
•	--filter-color-chars (optional): Removes ANSI color codes from lines before sending.
•	--filter-timestamps (optional): Removes timestamps at the start of lines.

Examples

1.	Basic Usage

Monitor a log file with a default polling delay of 1 second.

Example Workflow

1.	Start the program to monitor the specified file.
2.	Upon changes, new content is sent to the designated Telegram chat.
3.	If specified, color codes and timestamps are removed from each line before sending.

Requirements

•	Python 3.7+
•	Dependencies managed automatically upon installation.

License

This package is licensed under the MIT License.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests for improvements.

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

log2telegram-0.6.3.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

log2telegram-0.6.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file log2telegram-0.6.3.tar.gz.

File metadata

  • Download URL: log2telegram-0.6.3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.11

File hashes

Hashes for log2telegram-0.6.3.tar.gz
Algorithm Hash digest
SHA256 8717254354847c9d7ae1448f509d50d344d7c07d699f43949ea6175edc40b7bd
MD5 ed61d13a3c61939a6cbc3e6cf3f8d9ae
BLAKE2b-256 eed353ecf2cd858b07c0ab3ee38041136be1cadab7b900542ea4c073fa24ff9b

See more details on using hashes here.

File details

Details for the file log2telegram-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: log2telegram-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.11

File hashes

Hashes for log2telegram-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 48621dc508c4ea0b49dbf9857d3f7e519d653ec4fa14ac35f176462f05f9d076
MD5 b4e40b95c1beeaa3209536f5dad79ffc
BLAKE2b-256 890ac5e6d9f7a2b9e2f52e805305b7f28772e2583ef9bcff3076306a61f9aa18

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