loguru-discord


Nameloguru-discord JSON
Version 1.4.0 PyPI version JSON
download
home_pageNone
SummaryLightweight sink for Loguru that sends logs to Discord via webhook.
upload_time2024-08-25 04:07:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseNone
keywords discord logging loguru sink webhook
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Loguru-Discord

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/loguru-discord?label=Python) ![PyPI - Status](https://img.shields.io/pypi/status/loguru-discord?label=PyPI%20Status) ![PyPI - Downloads](https://img.shields.io/pypi/dm/loguru-discord?label=PyPI%20Downloads)

Lightweight sink for [Loguru](https://github.com/Delgan/loguru) that sends logs to [Discord](https://discord.com/) via webhook.

<p align="center">
    <img src="https://i.imgur.com/aS7wt4c.png" draggable="false">
</p>

## Usage

Construct a handler with your preferred options, then add a new sink to Loguru.

### Installation

Support is guaranteed only for Python 3.12 or greater.

Once this requirement is met, simply install via your package manager of choice.

```
pip install loguru-discord
```

### Example

The following code is a complete example which demonstrates:

-   Constructing a handler
-   Adding the handler as a Loguru sink
-   Catching an exception and firing a log

```py
from loguru import logger
from loguru_discord import DiscordSink

logger.add(DiscordSink("https://discord.com/api/webhooks/00000000/XXXXXXXX"))

try:
    value: float = 1 / 0
except Exception as e:
    logger.opt(exception=e).error("Lorem ipsum dolor sit amet")
```

## Customization

Upon constructing your handler, the following optional customizations are available via keyword arguments.

-   **Username**: Username to use for the Discord Webhook message.
-   **Avatar**: Image URL to use for the Discord Webhook message.
-   **Embed**: Toggle whether to use plain codeblock formatting or rich embeds.
-   **Truncate**: Toggle whether to trim lengthy logs instead of uploading as a file.
-   **Suppress**: Prevent specific Exception types from being sent to Discord.

## Releases

Loguru-Discord follows [Semantic Versioning](https://semver.org/) for tagging releases of the project.

## Contributing

Bug fixes and optimizations are always welcome. See [`CONTRIBUTING.md`](https://github.com/EthanC/Loguru-Discord/blob/master/.github/CONTRIBUTING.md) for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "loguru-discord",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "discord, logging, loguru, sink, webhook",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/67/b1/1e263ae40b8506741e19c05139bb89c8f13f752721ca0c6c215d2dcf3c87/loguru_discord-1.4.0.tar.gz",
    "platform": null,
    "description": "# Loguru-Discord\n\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/loguru-discord?label=Python) ![PyPI - Status](https://img.shields.io/pypi/status/loguru-discord?label=PyPI%20Status) ![PyPI - Downloads](https://img.shields.io/pypi/dm/loguru-discord?label=PyPI%20Downloads)\n\nLightweight sink for [Loguru](https://github.com/Delgan/loguru) that sends logs to [Discord](https://discord.com/) via webhook.\n\n<p align=\"center\">\n    <img src=\"https://i.imgur.com/aS7wt4c.png\" draggable=\"false\">\n</p>\n\n## Usage\n\nConstruct a handler with your preferred options, then add a new sink to Loguru.\n\n### Installation\n\nSupport is guaranteed only for Python 3.12 or greater.\n\nOnce this requirement is met, simply install via your package manager of choice.\n\n```\npip install loguru-discord\n```\n\n### Example\n\nThe following code is a complete example which demonstrates:\n\n-   Constructing a handler\n-   Adding the handler as a Loguru sink\n-   Catching an exception and firing a log\n\n```py\nfrom loguru import logger\nfrom loguru_discord import DiscordSink\n\nlogger.add(DiscordSink(\"https://discord.com/api/webhooks/00000000/XXXXXXXX\"))\n\ntry:\n    value: float = 1 / 0\nexcept Exception as e:\n    logger.opt(exception=e).error(\"Lorem ipsum dolor sit amet\")\n```\n\n## Customization\n\nUpon constructing your handler, the following optional customizations are available via keyword arguments.\n\n-   **Username**: Username to use for the Discord Webhook message.\n-   **Avatar**: Image URL to use for the Discord Webhook message.\n-   **Embed**: Toggle whether to use plain codeblock formatting or rich embeds.\n-   **Truncate**: Toggle whether to trim lengthy logs instead of uploading as a file.\n-   **Suppress**: Prevent specific Exception types from being sent to Discord.\n\n## Releases\n\nLoguru-Discord follows [Semantic Versioning](https://semver.org/) for tagging releases of the project.\n\n## Contributing\n\nBug fixes and optimizations are always welcome. See [`CONTRIBUTING.md`](https://github.com/EthanC/Loguru-Discord/blob/master/.github/CONTRIBUTING.md) for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Lightweight sink for Loguru that sends logs to Discord via webhook.",
    "version": "1.4.0",
    "project_urls": {
        "Changelog": "https://github.com/EthanC/Loguru-Discord/commits/main/",
        "Issues": "https://github.com/EthanC/Loguru-Discord/issues",
        "Repository": "https://github.com/EthanC/Loguru-Discord",
        "Twitter": "https://twitter.com/Mxtive"
    },
    "split_keywords": [
        "discord",
        " logging",
        " loguru",
        " sink",
        " webhook"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b25c567c8300194ad0833d17e2c9b6187a58a8e500969cb6641fab6703e1e0f9",
                "md5": "992f71454b8b5fa3a46a4d0b16f09cac",
                "sha256": "37ccc04a5c6de7996646734593d8ba430a0663f5cf844f79d31e6715fdf76163"
            },
            "downloads": -1,
            "filename": "loguru_discord-1.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "992f71454b8b5fa3a46a4d0b16f09cac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 5407,
            "upload_time": "2024-08-25T04:07:01",
            "upload_time_iso_8601": "2024-08-25T04:07:01.512307Z",
            "url": "https://files.pythonhosted.org/packages/b2/5c/567c8300194ad0833d17e2c9b6187a58a8e500969cb6641fab6703e1e0f9/loguru_discord-1.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67b11e263ae40b8506741e19c05139bb89c8f13f752721ca0c6c215d2dcf3c87",
                "md5": "4c6d6cb97b572ff6c070c1919bd4d58a",
                "sha256": "eab215b84f32c43406e601f9078803e810d3ee09d7e2717556708da8dbd381a2"
            },
            "downloads": -1,
            "filename": "loguru_discord-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4c6d6cb97b572ff6c070c1919bd4d58a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 14538,
            "upload_time": "2024-08-25T04:07:03",
            "upload_time_iso_8601": "2024-08-25T04:07:03.286013Z",
            "url": "https://files.pythonhosted.org/packages/67/b1/1e263ae40b8506741e19c05139bb89c8f13f752721ca0c6c215d2dcf3c87/loguru_discord-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-25 04:07:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EthanC",
    "github_project": "Loguru-Discord",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "loguru-discord"
}
        
Elapsed time: 0.40780s