Configurable Rendering Format (LogRender) #2534
Unanswered
AndreasBackx
asked this question in
Ideas
Replies: 1 comment 7 replies
-
This would shift the burden to the Rich, but the functionality belongs in the application's code. Don't rely on |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This follows #2520, it was a PR to implement the
console
parameter inrich.reconfigure
as it was added but never implemented. The PR was closed as it would not be the ideal solution, the conversation hopefully can continue here. 🙂The premise is that we have a internal libraries to simplify and standardise many parts of a CLI. An example is for
stderr
to be the default instead ofstdout
. This is achievable with the current implementation ofrich.reconfigure
. However, we additionally want to change the format of messages/renderables. This is currently controlled by a private_log_render.LogRender
. If this is to be configured,Console
needs to be subclassed and changed to "fake"LogRender
which is not ideal. I propose something along the lines below to perhaps make this configurable? This is just an idea, I thought that would hopefully get the conversation started.LogRenderer(Protocol[LogRenderOptions], ConsoleRenderable)
to replaceLogRender
. This would determine how a particular "log" is rendered.Log
to contain all of the information that needs to be logged. Making it a dataclass allows us to add fields in the future without breaking compatibility.TableLogRenderOptions
with the same implementation as the currentLogRender
and replace it inConsole
.This will allow custom formatting via
LogRenderer
and allow tweaking as well asLogRenderOptions
is configurable from theConsole
level.There also have been some other discussions and issues that want to change the format of Rich. These could be made possible with a custom renderer, whether they write that themselves, the default one is updated, or multiple renderers are included in Rich by default.
Let me know what you think. How would you tackle it or have you thought about this in the past? 😊
Beta Was this translation helpful? Give feedback.
All reactions