Skip to content

Commit

Permalink
docs: add python logger info
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-geller committed Sep 28, 2024
1 parent b583ce8 commit e4876bc
Showing 1 changed file with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,14 +45,47 @@
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})
beforeCommands:
- 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,
Expand Down

0 comments on commit e4876bc

Please sign in to comment.