Skip to main content

A package for sending logs to Telegram channels

Project description

LogGram

LogGram is a Python package for sending error logs and messages to Telegram channels or groups. It allows you to easily track errors and notifications in real-time using Telegram bots.

Features

  • Send error tracebacks to a specified Telegram channel or group
  • Support for both synchronous and asynchronous message sending
  • Configurable logging with file output
  • Easy setup and integration

Installation

pip install loggram

Usage

  1. Create a Telegram Bot:

    • Follow this guide to create a new bot and obtain your bot token.
    • Add the bot to your desired channel or group and promote it as an admin.
  2. Initialize LogGram: Here's an example of how to use LogGram in your project:

    from loggram import Loggram
    
    # Replace with your actual bot token and chat ID
    token = "YOUR_TELEGRAM_BOT_TOKEN"
    chat_id = "YOUR_TELEGRAM_CHAT_ID"
    
    # Create an instance of Loggram
    logger = Loggram(token, chat_id, verbose=True)
    
    # example
    try:
        1 / 0  # Code that raises an error
    except Exception as e:
        logger.send_traceback(str(e))
    

Contributing

Contributions are welcome! If you find a bug or have a suggestion, please open an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Security Notice

Important: Ensure the secure handling of your API keys and secrets. Do not hard code sensitive information directly in your source code. Consider using environment variables or a secure configuration management system to store and retrieve confidential data.

For example, you can use the python-decouple library along with a .env file to manage your project's configuration:

  1. Install python-decouple:

    pip install python-decouple
    
  2. Create a .env file in your project's root directory and add your secret information:

    SECRET_KEY=your_actual_secret_key
    
  3. In your code, use python-decouple to access your configuration variables:

    from decouple import config
    
    secret_key = config('SECRET_KEY')
    

By following secure practices, you help protect your application and sensitive data.

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

loggram-1.0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

loggram-1.0.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file loggram-1.0.2.tar.gz.

File metadata

  • Download URL: loggram-1.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.4

File hashes

Hashes for loggram-1.0.2.tar.gz
Algorithm Hash digest
SHA256 de2db02559607df2ca2c2f3683eaf7606aa0c347bc33baba6b41047bbb2075ce
MD5 295fc9024f61cf96d91669a4ef084358
BLAKE2b-256 be5d025e1b7b41c9b13d9ea51838ff6bc5307013565e0be01cc5069705153c71

See more details on using hashes here.

File details

Details for the file loggram-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: loggram-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.4

File hashes

Hashes for loggram-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8210448bf735fe0ce7788ac1de64e011187eb3105c0b79c1d519b3421f41100d
MD5 2932fd83b4004fad1077464009dcec4c
BLAKE2b-256 8e6481585a464a7f0f5bb1d084886a4d5d750a17a642769b776c3e03e01a527c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page