marimo
marimo copied to clipboard
Logging information
Documentation is
- [x] Missing
- [ ] Outdated
- [ ] Confusing
- [ ] Not sure?
Explain in Detail
It is unclear how to use logging with marimo. I want to be able to write log messages to the log console without having them show up in the output area. My use case is for writing a widget that runs in marimo
For the following code block. all 4 statements (including the print) show up in the marimo log console and the output area. In Jupyter you can control the level of the log console.
import logging
# Creating an object
logger = logging.getLogger()
logger.debug("debug from logger 5")
logger.info("debug from logger 5")
logger.error("error from logger 7")
print("print statement")
Your Suggestion for Changes
I would like a logging config that lets me target the marimo log console specifically. Targetting the jupyter log console would be helpful too but I understand if that is out of scope for your docs.
To the extent that it is possible to control the marimo log console from python code, examples of those instructions would be useful. I frequently want to programtically clear the log console, set the displayed log level of the log console, and control it's display state (show/hide). This is very useful when developing code/widgets.
Finally best practices around logging in marimo would be helpful. How do you all use logging?
I think you may be asking about https://docs.marimo.io/api/outputs/#console-outputs ?
I'm a little confused about what is meant by "console" here. It seems Marimo has a "console output area below a cell" as part of the notebook web UI. If that's what you want, and need to use it in an "app view", then I think it may already exist.
What I want, and haven't been able to figure out how to get, is logging to the console in the standard Unix sense: where stdout and stderr go when used from normal Python code. I need to be able to log custom messages for my Marimo app when deployed via Docker, just like I would with Flask or any other http server framework.
EDIT: The run server doesn't look like it's intended for my use case, although that's what the docker examples use. But I think I can do what I need with a "programmatic" deployment, as documented here: https://docs.marimo.io/guides/deploying/programmatically/
Hey @paddymul sorry this got lost in the back log.
You've been using marimo for about a month more now, did you find something that fit your needs? Otherwise yes, stdout/stderr displays (by default) under the cell
If I understand correctly, you want to log to the invoking terminal like mo-rn? What would be the ideal behavior you're looking for?
I would like to have commands or configurations that only write to the circled logging area, and don't write to the output area below the cell.
If everything writes below the cell, I can't really log debug messages because they will disrupt the user experience.