scverse / cookiecutter-scverse

Cookiecutter template for scverse
https://cookiecutter-scverse-instance.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
67 stars 8 forks source link

Unified logging and settings #72

Open grst opened 2 years ago

grst commented 2 years ago

Should we propose a default mechanism for logging and settings?

Benefits IMO would be consistent behaviour for all ecosystem packages. Ideally there would be a way to set the logging level for all scverse packages globally.

This could either be implemented as

In the long run, a "scverse-tools" package could make sense. We kinda have something like that already with scanpydoc, but could extend the scope to other helper functions.

Zethson commented 2 years ago

Big yes.

grst commented 2 years ago

Should include a function to get the session_info as in scanpy.loggin.print_versions()

adamgayoso commented 1 year ago

We should likely just use the standard logging module? We have a very basic setup with scvi-tools that uses rich to format the messages.

adamgayoso commented 1 year ago

https://github.com/Delgan/loguru looks interesting also

flying-sheep commented 1 year ago

Another interesting alternative that looks easier to understand (less magic API) and just as easy to use while encouraging to attach data to your log entries: https://www.structlog.org/en/stable/getting-started.html

If you have rich or better-exceptions installed, exceptions will be rendered in colors and with additional helpful information.

It also promotes logging json by default if the stdlib isn’t a TTY which I really like: https://www.structlog.org/en/stable/logging-best-practices.html#pretty-printing-vs-structured-output

See here how it integrates with the stdlib: https://www.structlog.org/en/stable/getting-started.html#structlog-and-standard-library-s-logging