a bridge between loguru & rich, rich's powerful render in loguru!
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file richuru-0.1.1.tar.gz
.
File metadata
- Download URL: richuru-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 815816f3a0142b67c53bd424fcced0821aa1104b5386301cff47fc7bbb6d90ea |
|
MD5 | a2293c9b32645f23f14efef1d5995acd |
|
BLAKE2b-256 | ce7cc9d4c0b541c9c6ba7d1898fb1886aad5a0d5dea43237a3154a9143d511b9 |
File details
Details for the file richuru-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: richuru-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73d43913a372d741ff61106001b5e6adfa24c6d0665dd390328a33e34cd210d |
|
MD5 | ac1aa5a7227154eaff298ea4bc764516 |
|
BLAKE2b-256 | 97752c59747e6a68e7e1f3df65b1133c03b27fd889c6e975a8539570bf5a9b68 |