richuru - Using Rich in Loguru to colour the logs
简体中文 | English
richuru is a lightweight dependency that provides rich's powerful terminal rendering support for loguru.
This project is sourced and independent from the component graia.amnesia.log of Graia Amnesia,
and is modified from the original implementation of @BlueGlassBlock.
Quick Start
Install richuru:
elaina@localhost $ pip install richuru
elaina@localhost $ pdm add richuru
elaina@localhost $ poetry add richuru
Try it in REPL:
>>> import richuru
>>> richuru.install()
>>>
>>> from loguru import logger
>>> logger.info("Hello World!", alt="Hello, [bold magenta]World[/bold magenta]!")
richuru is designed as an optional dependency, which means that you need to provide a fallback pattern when using richuru wherever possible, to be compatible with end-users who do not have richuru enabled.
Provide alt in logger.<method>(...) with the alt option to make richuru recognize and enable rich's rich text functionality.
Of course, you can also specify an entire entry's rich text style without using alt:
logger.info("i'm in rich!", style="bold red")
which is equivalent to :
logger.info("i'm in rich!", alt="[bold red]i'm in rich![/]")
# without richuru: no, you are not in rich :P
Print the ConsoleRenderable object:
from rich.markdown import Markdown
with open("README.md") as readme:
markdown = Markdown(readme.read())
logger.info("fallback msg", rich=markdown)
This works with static elements like Table, Markdown, and dynamic elements like Status, Progress, which have not been tested yet.
Open Source License
This project is open source under the MIT License.
Metadata
Release files for richuru 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| richuru-0.1.1.tar.gz | 4.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| richuru-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / richuru-0.1.1.tar.gz
| Download URL | richuru-0.1.1.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
815816f3a0142b67c53bd424fcced0821aa1104b5386301cff47fc7bbb6d90ea
|
|
BLAKE2b-256 checksum How to use checksums |
ce7cc9d4c0b541c9c6ba7d1898fb1886aad5a0d5dea43237a3154a9143d511b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.64.0 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Release files / richuru-0.1.1-py3-none-any.whl
| Download URL | richuru-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e73d43913a372d741ff61106001b5e6adfa24c6d0665dd390328a33e34cd210d
|
|
BLAKE2b-256 checksum How to use checksums |
97752c59747e6a68e7e1f3df65b1133c03b27fd889c6e975a8539570bf5a9b68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.64.0 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Security for richuru 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.