diff --git a/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/Script.java b/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/Script.java index 18cf1e7..d9c3056 100644 --- a/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/Script.java +++ b/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/Script.java @@ -32,7 +32,7 @@ @Plugin( examples = { @Example( - title = "Execute a Python script.", + title = "Execute a Python script and generate an output.", full = true, code = """ id: python_use_input_file @@ -45,7 +45,7 @@ from kestra import Kestra import requests - response = requests.get('https://google.com') + response = requests.get('https://kestra.io') print(response.status_code) Kestra.outputs({'status': response.status_code, 'text': response.text}) @@ -53,6 +53,39 @@ - pip install requests kestra """ ), + @Example( + title = "Log messages at different log levels using Kestra logger.", + full = true, + code = """ + id: python_logs + namespace: company.team + + tasks: + - id: python_logger + type: io.kestra.plugin.scripts.python.Script + allowFailure: true + warningOnStdErr: false + 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.") + """ + ), @Example( title = "Execute a Python script with an input file from Kestra's local storage created by a previous task.", full = true,