ui.log - support for coloring lines #2508
Replies: 4 comments
-
Indeed, this would be helpful. We would be happy to review any pull requests in this direction. |
Beta Was this translation helpful? Give feedback.
-
I wonder how this could be done conceptually. Should we accept an optional color per line? Or should we add general support for HTML or maybe ANSI escape codes? And is it possible to keep using the existing implementation or should we switch to a more powerful JavaScript library like xterm.js (see #1846)? |
Beta Was this translation helpful? Give feedback.
-
On an API level the push function could get a color per line, or stylesheet definition, at least for my use-case. There might be cases where a more general support would be helpful (e.g., error messages in clang can highlight parts of the line to indicate clearly where a problem is). On the technical side, I am not sure how to even get started. As stated in the initial feature request, the current implementation uses an textarena, which seems to only allow a single style for the whole text. |
Beta Was this translation helpful? Give feedback.
-
I am simply prepending icons: LOG_LEVEL_ICONS = {
logging.DEBUG: "🐞",
logging.INFO: "ℹ️",
logging.WARNING: "⚠️",
logging.ERROR: "❌",
logging.CRITICAL: "🔥",
} |
Beta Was this translation helpful? Give feedback.
-
It would be nice if individual lines in ui.log could be colored (e.g., yellow for warnings, red for errors).
On the technical side, ui.log currently uses an html textarea, which does not support different text properties, as far as I know. (See https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/log.py and https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/log.js).
Beta Was this translation helpful? Give feedback.
All reactions