Logging in Tethys Apps #655
swainn
started this conversation in
Tips and Tricks
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Import logging at the top of the module:
Immediately after your imports, get a unique logger for your app, but using the
"tethys"
namespace so that logs are captured in the Tethys logs/console:Use the various logger methods in your code to categorize your log statements:
log.info("Some message")
: normal operation information messages. Keep these to a minimum to avoid impacting the performance of your server.log.warning("Some message")
: minor issues encountered that won't prevent the application from running.log.error("Some message")
: known/handled errors that are encountered.log.critical("Some message")
: issues that need imlog.exception("Some message")
: unexpected errors, logs more detailed information about the exception including the traceback in addition to the error that occurred.log.debug("Some message")
: verbose information for debugging issues in production. I often convert many of my print statements used for development into debug statements.Note that different messages will be logged depending on the log level. The log level for configuring Tethys can be configured in the portal_config.yml
LOGGING
setting in http://docs.tethysplatform.org/en/stable/tethys_portal/configuration.html#portal-yaml-keysFor more information about logging in Python see: https://docs.python.org/3.7/library/logging.html
Beta Was this translation helpful? Give feedback.
All reactions