Add documentation

This commit is contained in:
Joe Halliwell 2021-12-12 11:17:48 +00:00
parent 64b921727d
commit 23daac5d01
1 changed files with 5 additions and 1 deletions

View File

@ -16,10 +16,14 @@ Here's an example of how to set up a rich logger::
log = logging.getLogger("rich") log = logging.getLogger("rich")
log.info("Hello, World!") log.info("Hello, World!")
Rich logs won't render :ref:`console_markup` in logging by default as most libraries won't be aware of the need to escape literal square brackets, but you can enable it by setting ``markup=True`` on the handler. Alternatively you can enable it per log message by supplying the ``extra`` argument as follows:: Rich logs won't render :ref:`console_markup` in logging by default as most libraries won't be aware of the need to escape literal square brackets, but you can enable it by setting ``markup=True`` on the handler. Alternatively you can enable it per log message by supplying the ``extra`` argument as follows::
log.error("[bold red blink]Server is shutting down![/]", extra={"markup": True}) log.error("[bold red blink]Server is shutting down![/]", extra={"markup": True})
Similarly, the highlighter may be overridden per log message::
log.error("123 will not be highlighted", extra={"highlighter": None})
Handle exceptions Handle exceptions
------------------- -------------------