log2telegram


Namelog2telegram JSON
Version 0.6.5 PyPI version JSON
download
home_pageNone
Summary🦜 A CLI tool to monitor a file and send updates to Telegram.
upload_time2025-01-16 01:36:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords log2telegram
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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=<your-telegram-bot-token>
LOG2TELEGRAM_CHAT_ID=<your-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 <file-path> [--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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "log2telegram",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "\"A. Great Maintainer\" <maintainer@example.com>",
    "keywords": "log2telegram",
    "author": null,
    "author_email": "Andrew Levin <author@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/af/20/86746d93052f618c964bb33bef291bef070f9428600dc2e8601a4ab6240c/log2telegram-0.6.5.tar.gz",
    "platform": null,
    "description": "# log2telegram\n\nlog2telegram 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.\n\nFeatures\n\n\t\u2022\tReal-Time Monitoring: Continuously watches for changes in a log file, sending new content as Telegram messages.\n\t\u2022\tConfigurable Delay: Set a custom interval for checking the file for changes.\n\t\u2022\tFiltering Options: Remove ANSI color codes and timestamps at the start of lines for cleaner messages.\n\t\u2022\tCustomizable Message Splitting: Automatically splits messages if they exceed the Telegram message size limit.\n\t\u2022\tError Handling and Logging: Logs errors if the file is unreadable, ensuring smooth operation and easy debugging.\n\nInstallation\n\nYou can install the package via PyPI:\n\npip install log2telegram\n\nSetup\n\nTo use log2telegram, add the following environment variables to a .env file:\n\nLOG2TELEGRAM_BOT_TOKEN=<your-telegram-bot-token>\nLOG2TELEGRAM_CHAT_ID=<your-chat-id>\n\n\t\u2022\tLOG2TELEGRAM_BOT_TOKEN: Your Telegram bot token, obtained from BotFather.\n\t\u2022\tLOG2TELEGRAM_CHAT_ID: The chat ID where messages will be sent.\n\nUsage\n\nRun the log2telegram command to monitor a file for changes. You can specify the path to the file and set optional flags for filtering.\n\nCommand-Line Arguments\n\nlog2telegram <file-path> [--seconds_delay SECONDS] [--filter-color-chars] [--filter-timestamps]\n\n\t\u2022\t<file-path> (required): The path to the file to monitor.\n\t\u2022\t--seconds_delay (optional): Interval in seconds between each check (default: 1). Must be a positive integer.\n\t\u2022\t--filter-color-chars (optional): Removes ANSI color codes from lines before sending.\n\t\u2022\t--filter-timestamps (optional): Removes timestamps at the start of lines.\n\nExamples\n\n\t1.\tBasic Usage\nMonitor a log file with a default polling delay of 1 second.\n\nExample Workflow\n\n\t1.\tStart the program to monitor the specified file.\n\t2.\tUpon changes, new content is sent to the designated Telegram chat.\n\t3.\tIf specified, color codes and timestamps are removed from each line before sending.\n\nRequirements\n\n\t\u2022\tPython 3.7+\n\t\u2022\tDependencies managed automatically upon installation.\n\nLicense\n\nThis package is licensed under the MIT License.\n\nContributing\n\nContributions are welcome! Feel free to open issues or submit pull requests for improvements.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\ud83e\udd9c A CLI tool to monitor a file and send updates to Telegram.",
    "version": "0.6.5",
    "project_urls": {
        "Bug Reports": "https://github.com/andrewalevin",
        "Funding": "https://donate.pypi.org",
        "Homepage": "https://github.com/andrewalevin",
        "Say Thanks!": "https://github.com/andrewalevin",
        "Source": "https://github.com/andrewalevin"
    },
    "split_keywords": [
        "log2telegram"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ade524986efd36dc95dd29c7c05a2e8af19060095b1981218be9db66a2dd5eaf",
                "md5": "1bad5b4c0a8a324b650cb476055c3290",
                "sha256": "ac6944eeb672627188215e280e185d725b1c2391aeb294251ac0cec2a579bd1c"
            },
            "downloads": -1,
            "filename": "log2telegram-0.6.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1bad5b4c0a8a324b650cb476055c3290",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11416,
            "upload_time": "2025-01-16T01:36:55",
            "upload_time_iso_8601": "2025-01-16T01:36:55.710585Z",
            "url": "https://files.pythonhosted.org/packages/ad/e5/24986efd36dc95dd29c7c05a2e8af19060095b1981218be9db66a2dd5eaf/log2telegram-0.6.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af2086746d93052f618c964bb33bef291bef070f9428600dc2e8601a4ab6240c",
                "md5": "250880c414f04f1190e3db9de35c6d3c",
                "sha256": "ae8270c66018618bdc7efdce1819b9021ed876944e57d925f6d0c3d3d49b6ee5"
            },
            "downloads": -1,
            "filename": "log2telegram-0.6.5.tar.gz",
            "has_sig": false,
            "md5_digest": "250880c414f04f1190e3db9de35c6d3c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11995,
            "upload_time": "2025-01-16T01:36:57",
            "upload_time_iso_8601": "2025-01-16T01:36:57.919845Z",
            "url": "https://files.pythonhosted.org/packages/af/20/86746d93052f618c964bb33bef291bef070f9428600dc2e8601a4ab6240c/log2telegram-0.6.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-16 01:36:57",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "log2telegram"
}
        
Elapsed time: 1.59091s