Replies: 3 comments
-
Thank you for your issue. Give us a little time to review it. PS. You might want to check the FAQ if you haven't done so already. This is an automated reply, generated by FAQtory |
Beta Was this translation helpful? Give feedback.
-
It clearly works! It's clever, but a bit of a hack. Can't promise it won't fail because of missing methods. It would be a little more work, but you could build a logging handler that writes to a given log widget. A good starting point would be Textual's logging handler which could be extended to also write to a widget. |
Beta Was this translation helpful? Give feedback.
-
Leaving this here in case anyone finds it useful - I used this logging trick in a project and kept getting logs bleeding through the app because they were still being written to the default stdout - to prevent these message duplications just add Thanks for the great library! |
Beta Was this translation helpful? Give feedback.
-
I would like to have a widget that I can use on e.g. a debug screen that works with the python logger. So the result is logs are written in the app itself (and not to an extra instance of the textual console). After some fiddling around, I think I came up with something workable. So I am basically answering my own question, but perhaps this is useful, or there is a better way or this can be included in a less hacky way.
The main idea is to leverage the
RichLog
as Widget, and theRichHandler
as log handler. The hack is that the RichHandler.console is replaced by the RichLog, like so:No when used in an app, everything logger using the
logging
module is shown in the logging widget:Results in:
Beta Was this translation helpful? Give feedback.
All reactions