I’m trying to find an elegant solution to a functional requirement I have. I want to have in my dash app a DIV that will display (for a short time) any logical error / warning / log message that my application logic will raise. This could be in any callback.
As I recall, it is not possible for multiple callbacks to share the same Output, but even if it was, having the same Output in every single callback would not be elegant.
Use the standard Python logging module with a log handler that writes the logs to a file. Add an interval component to trigger a callback, which reads the log file and writes its content to the DIV.
Interesting idea. But how would the callback trigger? Based on what? Based on the file date/size changing? Is that even possible?
(I may not fully understand what you mean by “internal component” I guess?)
Wouldn’t that be awfully inefficient? To be “reactive” (ie. react to incorrect user input for example), it would have to be triggered at least every half second…
I wouldn’t recommend going below 1s though. If you need something that fast, you should use a client side solution, e.g. a custom React. It might also be possible to use a websocket depending on your needs.