diff --git a/python-generate-logs.yaml b/python-generate-logs.yaml new file mode 100644 index 0000000..8d109dc --- /dev/null +++ b/python-generate-logs.yaml @@ -0,0 +1,43 @@ +id: python-generate-logs +namespace: company.team + +tasks: + - id: python_logger + type: io.kestra.plugin.scripts.python.Script + allowFailure: true + warningOnStdErr: false + beforeCommands: + - pip install kestra + script: | + import time + from kestra import Kestra + + logger = Kestra.logger() + + logger.debug("DEBUG is used for diagnostic info.") + time.sleep(0.5) + + logger.info("INFO confirms normal operation.") + time.sleep(0.5) + + logger.warning("WARNING signals something unexpected.") + time.sleep(0.5) + + logger.error("ERROR indicates a serious issue.") + time.sleep(0.5) + + logger.critical("CRITICAL means a severe failure.") +extend: + title: Run a Python script and capture logs + description: >- + This flow generates logs using the `Kestra.logger()` method from the [Kestra pip package](https://github.com/kestra-io/libs) + to instantiate a `logger` object — this logger is configured to correctly capture all Python log + levels and send them to the Kestra backend. + + tags: + - Python + - pip + - Software Engineering + ee: false + demo: true + meta_description: This flow generates a number of logs at different levels using the `Kestra.logger()` method