Skip to content

Commit

Permalink
feat: python logs blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
wrussell1999 authored Nov 8, 2024
1 parent 16c3b18 commit e1f8546
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions python-generate-logs.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e1f8546

Please sign in to comment.