Hello all, I ran a dash program overnight to test some data gathering functions, and this morning I see a bunch of things offline/sending errors. However, there are 7k error messages and the RPI dash is running on cant keep up with them to allow me to read them. Is there any way for me to export the error traceback messages so I can read them without touching the dev tool bar? Some errors are in the terminal, but I’d like to be able to see the ones in dash. Thanks!
Hey @Pine_Owple not exactly sure what you are referring to bit did you try a forum search?
https://community.plotly.com/search?q=error%20logging%20order%3Alatest
Im referring to the errors and tracebacks you see in this screen:
Haven’t had luck with searching the forum, the closest thing I found was this post. But they couldn’t get the tracebacks into the terminal, and I don’t necessarily want it in the terminal. I want it to be any legible form, that could get saved, and the terminal has character limits that mean I would miss the most important initial messages.
Sorry I can´t help any further, I guess this would go deep into the JS part of dash. After seeing this thread, maybe @CNFeffery can share some thoughts on this.
Maybe on a different not: the errors you see in the log are caused by errors in the code used to set up the app.
I catch errors by having a custom callback decorator. The actual callback is then wrapped in a try/except block. In except case, I send a notification to the end user and log the full error in a log file (traceback.format_exc()) gives you the traceback info you need to debug. Nice side effect is, that I do not have to worry so much about error handling in the actual callback, as it is managed generically by the callback decorator. I unfortunately cannot post my solution (as I developed it as part of my job and is thereby not my IP), but below is the high-level idea how to implement it.
def callback_handler(*arg): #use @callback_handler instead of @callback in your app
def decorator(func):
@wraps(func)
def wrapper(*func_args, **func_kwargs):
try:
result = func(*func_args, **func_kwargs) # execute the callback function
[...]
except:
# error_log + send notifcation to user (e.g., using set_props)
result = callback(*args, **kwargs)(wrapper)
return result
return decorator
However, it might be even easier with hooks nowadays, but as my solution works I have no attention of switching.
Thanks for sharing @mgg1
Could you share your thoughts on how to accomplish something similar using hooks?
I have not used hooks at all yet, so unfortunately I have no answer for you.
