kopf icon indicating copy to clipboard operation
kopf copied to clipboard

Print statement from example does not show up in logs for me but logging lib works

Open kopf-archiver[bot] opened this issue 4 years ago • 1 comments

An issue by janvdvegt at 2020-01-26 20:37:09+00:00 Original URL: https://github.com/zalando-incubator/kopf/issues/300  

Long story short

Print statements do not show up in logs in bare bones example. Replacing them with logging.info works.

Description

Example code from docs:

import kopf

 @kopf.on.create('zalando.org', 'v1', 'ephemeralvolumeclaims')
 def create_fn(body, **kwargs):
     print(f"A handler is called with body: {body}")

This does work:

import kopf
import logging

 @kopf.on.create('zalando.org', 'v1', 'ephemeralvolumeclaims')
 def create_fn(body, **kwargs):
     logging.info(f"A handler is called with body: {body}")

I tried to set PYTHONUNBUFFERED to 0 but this did not matter.

Environment

  • Kopf version: 0.24
  • Kubernetes version: 0.12.4
  • Python version: 3.7
  • OS/platform: MacOS

By using the logging library it does not block me in whatever way but the base example does not work for me so I just wanted to notify you

kopf-archiver[bot] avatar Aug 18 '20 20:08 kopf-archiver[bot]

Opened a PR for this - https://github.com/nolar/kopf/pull/893

alexdyas avatar Feb 10 '22 10:02 alexdyas