## Logging This section will go over how to properly log messages in Elyra ### Pipelines Extension Logging #### Python The Kubeflow Pipelines extension uses a custom IPython handler to handle interactions with the Notebook server instance. By extending the IPython handler we are able to leverage Tornado logging since the Jupyter Notebook server uses Tornado as its web framework.
###### Pipelines -> IPythonHandler -> Tornado.log -> lib/logging
##### When to add log messages Use INFO level for routines(functions), like when handling requests or state changes and DEBUG for troubleshooting and diagnostics.
``` def foo (arg): self.debug.info(f"doing something with this {arg}") do something with arg self.log.info(f"Result of arg is ... {result}") ``` Use WARNING level when it is important, but not an error, for example, when a user attempts to login with an incorrect password
``` def authenticate(username, password): if username and password doesn't work: self.log.warn(f"Failed login attempt from {username} : {password}") ``` Use ERROR level when something is actually wrong, like when an exception is thrown, IO operation failure or connectivity issue (e.g. Minio client cant connect to endpoint)
``` try: if not minio_client.bucket_exists(bucket_name): minio_client.make_bucket(bucket_name) except ResponseError: self.log.error("Minio error", exc_info=True) ``` ##### Adding log messages Add log messages by inserting statements as follows:
`self.log.debug("insert debug message", *args, *kwargs)`
Use the appropriate logging levels when inserting specific messages e.g. log.debug, log.warn etc.
The log output will be color coded, legend as follows:
| Log Level | Color |
|-----------|-------|
| DEBUG | Blue |
| INFO | Green |
| WARNING | Yellow |
| ERROR | Red |
| CRITICAL | Magenta |
##### Setting the Log Level
The default Log Level is set to INFO. If you need to increase log verbosity, you can start Jupyterlab with
the `--debug` option for example:
```
jupyter lab --debug