openfaas / python-flask-template

HTTP and Flask-based OpenFaaS templates for Python 3
MIT License
84 stars 84 forks source link

support request: logging #24

Closed fopina closed 5 years ago

fopina commented 5 years ago

As HTTP mode no longer needs IO to exchange data with watchdog, are both of them free for logging? I've tried using combine_output: false and use stderr but I always get an error.

handler.py

import sys

def handle(event, context):
    sys.stderr.write('foo\n')
    sys.stdout.write('bar\n')
    return {
        "statusCode": 200,
        "body": "Hello from OpenFaaS!"
    }

function.yml

version: 1.0
provider:
  name: openfaas
  gateway: http://127.0.0.1:8080
functions:
  mytest:
    lang: python3-http
    handler: ./mytest
    image: mytest:latest

And the error output for first curl to the function

mytest.1.xov05txbh055@docker-desktop    | 2019/09/10 00:08:39 SIGTERM received.. shutting down server in 10s
mytest.1.xov05txbh055@docker-desktop    | 2019/09/10 00:08:39 Removing lock-file : /tmp/.lock
mytest.1.xov05txbh055@docker-desktop    | 2019/09/10 00:08:39 Error reading stderr: EOF

Following requests do not log any errors but don't log any foobar either...