xwarning


Namexwarning JSON
Version 0.15 PyPI version JSON
download
home_pagehttps://github.com/cumulus13/xwarning
SummaryEnhanced warning output using Rich with icons and colors.
upload_time2025-07-25 16:11:53
maintainerNone
docs_urlNone
authorHadi Cahyadi
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # xwarning

`xwarning` is a Python module that enhances the default `warnings` system using [Rich](https://github.com/Textualize/rich), providing beautiful, color-coded warning messages with icons.

## Features

- Emoji-based warning indicators
- Rich-colored terminal output
- Drop-in replacement for `warnings.warn()`
- Built-in support for common warning types:
  - `DeprecationWarning`
  - `UserWarning`
  - `FutureWarning`
  - `RuntimeWarning`
  - `SyntaxWarning`
  - `ImportWarning`
  - `UnicodeWarning`
  - Generic `Warning`
- Optional file logging:
  - If `log_file` is a string, logs to the specified filename
  - If `True`, logs to system temp directory (Windows) or `/var/log` (Linux)
- Fully configurable:
  - Toggle icons on/off
  - Toggle colors on/off


## Installation

```bash
pip install xwarning
```

## Usage

```python
>> from xwarning import warn, warning, configure

# Simple usage you can use 'warn' similar as 'warning'
>> warn("This is deprecated warning !", type="deprecated")

>> warn("This is user warning !", type="user")

>> warn("This is future warning !", type="future")

>> warn("This is runtime warning !", type="runtime")

>> warn("This is syntax warning !", type="syntax")

>> warn("This is import warning !", type="import")

>> warn("This is unicode warning !", type="unicode")

>> warn("This is general warning !", type="general")

>> configure(show_icon=False, show_color=True)

# Logging to file
>> log_path = "warnings.log"
>> configure(log_file=log_path)

>> warn(f"This will go to the log file! with log file name '{log_path}'", type="user")

>> log_path = True
>> configure(log_file=log_path)
>> warn(f"This will go to the log file! with log file name as bool in temp or /var/log directory", type="user")

# Extra instance
>> printer1 = WarningPrinter()
>> printer1.configure(show_icon=False, log_file=True)
>> printer1.warn("this user warning with printer1", type="user")

>> printer2 = WarningPrinter()
>> printer2.configure(show_icon=True, show_color=False)
>> printer2.warn("this runtime warning with printer2", type="runtime")

>> printer1.filterwarnings("ignore", category=UserWarning)

>> printer1.warn("This not will appear as a user warning with `filterwarning`", type="user")
>> printer1.warn("This will appear as a runtime warning without `filterwarning`", type="runtime")


```

## Example Output

```
🛑 DEPRECATED: This is deprecated
⚠️ USER: This is a user warning!
```

[![Example Outputs](https://github.com/cumulus13/xwarning/raw/refs/heads/master/example_outputs.png)](https://github.com/cumulus13/xwarning/raw/refs/heads/master/example_outputs.png)


## License

MIT License. See [LICENSE](./LICENSE) for details.

## author
[Hadi Cahyadi](mailto:cumulus13@gmail.com)
    

[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)

[![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)

[Support me on Patreon](https://www.patreon.com/cumulus13)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cumulus13/xwarning",
    "name": "xwarning",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Hadi Cahyadi",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/35/e1/dee41bcfe8cb63e37b742cd958547eeed7eea0ad7fb9c9542d8399886ad6/xwarning-0.15.tar.gz",
    "platform": null,
    "description": "# xwarning\r\n\r\n`xwarning` is a Python module that enhances the default `warnings` system using [Rich](https://github.com/Textualize/rich), providing beautiful, color-coded warning messages with icons.\r\n\r\n## Features\r\n\r\n- Emoji-based warning indicators\r\n- Rich-colored terminal output\r\n- Drop-in replacement for `warnings.warn()`\r\n- Built-in support for common warning types:\r\n  - `DeprecationWarning`\r\n  - `UserWarning`\r\n  - `FutureWarning`\r\n  - `RuntimeWarning`\r\n  - `SyntaxWarning`\r\n  - `ImportWarning`\r\n  - `UnicodeWarning`\r\n  - Generic `Warning`\r\n- Optional file logging:\r\n  - If `log_file` is a string, logs to the specified filename\r\n  - If `True`, logs to system temp directory (Windows) or `/var/log` (Linux)\r\n- Fully configurable:\r\n  - Toggle icons on/off\r\n  - Toggle colors on/off\r\n\r\n\r\n## Installation\r\n\r\n```bash\r\npip install xwarning\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\n>> from xwarning import warn, warning, configure\r\n\r\n# Simple usage you can use 'warn' similar as 'warning'\r\n>> warn(\"This is deprecated warning !\", type=\"deprecated\")\r\n\r\n>> warn(\"This is user warning !\", type=\"user\")\r\n\r\n>> warn(\"This is future warning !\", type=\"future\")\r\n\r\n>> warn(\"This is runtime warning !\", type=\"runtime\")\r\n\r\n>> warn(\"This is syntax warning !\", type=\"syntax\")\r\n\r\n>> warn(\"This is import warning !\", type=\"import\")\r\n\r\n>> warn(\"This is unicode warning !\", type=\"unicode\")\r\n\r\n>> warn(\"This is general warning !\", type=\"general\")\r\n\r\n>> configure(show_icon=False, show_color=True)\r\n\r\n# Logging to file\r\n>> log_path = \"warnings.log\"\r\n>> configure(log_file=log_path)\r\n\r\n>> warn(f\"This will go to the log file! with log file name '{log_path}'\", type=\"user\")\r\n\r\n>> log_path = True\r\n>> configure(log_file=log_path)\r\n>> warn(f\"This will go to the log file! with log file name as bool in temp or /var/log directory\", type=\"user\")\r\n\r\n# Extra instance\r\n>> printer1 = WarningPrinter()\r\n>> printer1.configure(show_icon=False, log_file=True)\r\n>> printer1.warn(\"this user warning with printer1\", type=\"user\")\r\n\r\n>> printer2 = WarningPrinter()\r\n>> printer2.configure(show_icon=True, show_color=False)\r\n>> printer2.warn(\"this runtime warning with printer2\", type=\"runtime\")\r\n\r\n>> printer1.filterwarnings(\"ignore\", category=UserWarning)\r\n\r\n>> printer1.warn(\"This not will appear as a user warning with `filterwarning`\", type=\"user\")\r\n>> printer1.warn(\"This will appear as a runtime warning without `filterwarning`\", type=\"runtime\")\r\n\r\n\r\n```\r\n\r\n## Example Output\r\n\r\n```\r\n\ud83d\uded1 DEPRECATED: This is deprecated\r\n\u26a0\ufe0f USER: This is a user warning!\r\n```\r\n\r\n[![Example Outputs](https://github.com/cumulus13/xwarning/raw/refs/heads/master/example_outputs.png)](https://github.com/cumulus13/xwarning/raw/refs/heads/master/example_outputs.png)\r\n\r\n\r\n## License\r\n\r\nMIT License. See [LICENSE](./LICENSE) for details.\r\n\r\n## author\r\n[Hadi Cahyadi](mailto:cumulus13@gmail.com)\r\n    \r\n\r\n[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)\r\n\r\n[![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)\r\n\r\n[Support me on Patreon](https://www.patreon.com/cumulus13)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Enhanced warning output using Rich with icons and colors.",
    "version": "0.15",
    "project_urls": {
        "Homepage": "https://github.com/cumulus13/xwarning"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf635b69c37136ff2c7fe4e70423f084a154cb7493ea2d610eebd018493cce7b",
                "md5": "a02dc463972fad80213ffc1968131531",
                "sha256": "0fe71b545d19939d611fd840b62ab870dff08cf18bbc3aea73bc21934bc47567"
            },
            "downloads": -1,
            "filename": "xwarning-0.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a02dc463972fad80213ffc1968131531",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6230,
            "upload_time": "2025-07-25T16:11:52",
            "upload_time_iso_8601": "2025-07-25T16:11:52.261537Z",
            "url": "https://files.pythonhosted.org/packages/bf/63/5b69c37136ff2c7fe4e70423f084a154cb7493ea2d610eebd018493cce7b/xwarning-0.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35e1dee41bcfe8cb63e37b742cd958547eeed7eea0ad7fb9c9542d8399886ad6",
                "md5": "e360108c37c3cc08a3a4fee7d9d2c786",
                "sha256": "f075e7906e5502e52220ea1e0c0fcd946903692dcb71ff76fa2a6c6163858176"
            },
            "downloads": -1,
            "filename": "xwarning-0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "e360108c37c3cc08a3a4fee7d9d2c786",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6110,
            "upload_time": "2025-07-25T16:11:53",
            "upload_time_iso_8601": "2025-07-25T16:11:53.974446Z",
            "url": "https://files.pythonhosted.org/packages/35/e1/dee41bcfe8cb63e37b742cd958547eeed7eea0ad7fb9c9542d8399886ad6/xwarning-0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-25 16:11:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cumulus13",
    "github_project": "xwarning",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "xwarning"
}
        
Elapsed time: 1.23798s