Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better description of logging in python flask templates #228

Open
2 of 3 tasks
martindekov opened this issue May 6, 2020 · 3 comments
Open
2 of 3 tasks

Better description of logging in python flask templates #228

martindekov opened this issue May 6, 2020 · 3 comments

Comments

@martindekov
Copy link
Contributor

My actions before raising this issue

Python based templates which use flask doesn't "just work" when it comes to logging. The general:

write_debug: true

in the environmental variables flag doesn't efficiently enable logging. It is not clearly explained how to enable logging in the http/flask based python templates:

Expected Behaviour

Enabling write_debug: true flag in environmental variables and hope writing to STDERR/STDOUT would show logs when using the faas-cli logs feature. If not I would be able to find steps which will let me log from Flask based python images in the documentation or somewhere else.

Current Behaviour

Enabling write_debug: true flag in environmental variables doesn't log to STDERR/STDOUT and it is troublesome to find out how to enable logging.

Possible Solution

Better documentation of explicit steps which will make Flask/Http based python templates to "just work" when it comes to logging. We should discuss whether this could be fixed in the templates themselves, or we should go with better documentation/workaround for the logs in Python Flask.

Steps to Reproduce (for bugs)

1.Add in stack.yml for some function which uses the http python templates which use Flask:

environment:
    write_debug: true

2.Write to stderr in the handler funciton:

import sys


def handle(req):
...
    sys.stderr.write("some msg")
...
  1. See the message in logs missing.
  2. Try searching it in the official docs where logs are mentioned and see flask is not explained.

Context

Opening an Issue was requested as per conversation in Slack. It was troublesome to find out documentation on how exactly should logging happen in Python Flask templates.

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ):
    N/A
  • Docker version docker version (e.g. Docker 17.0.05 ):
    N/A
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    N/A
  • Operating System and version (e.g. Linux, Windows, MacOS):
    N/A
  • Code example or link to GitHub repo or gist to reproduce problem:
    N/A
  • Other diagnostic information / logs from troubleshooting guide

Next steps

You may join Slack for community support.

@alexellis
Copy link
Member

Please go ahead with this @martindekov - best suited to the docs repo I'd say.

@alexellis alexellis transferred this issue from openfaas/faas Jun 15, 2020
@martindekov
Copy link
Contributor Author

I remember we had a discussion in slack what is the best approach for this. I am wondering did we reach a conclusion? I will go through logging in flask templates again just in case

@108356037
Copy link

108356037 commented Nov 29, 2021

Hi, is there any news on enabling logging in python http template?
I've set the write_debug env to true, but getting container logs like below:

2021-11-29T09:56:00Z 2021/11/29 09:56:00 POST / - 200 OK - ContentLength: 17
2021-11-29T09:57:00Z 2021/11/29 09:57:00 POST / - 200 OK - ContentLength: 17
2021-11-29T09:58:00Z 2021/11/29 09:58:00 POST / - 200 OK - ContentLength: 17
2021-11-29T09:59:00Z 2021/11/29 09:59:00 POST / - 200 OK - ContentLength: 17
2021-11-29T10:00:00Z 2021/11/29 10:00:00 POST / - 200 OK - ContentLength: 17

Or is logging available but haven't been written in the docs?
Any guide will be appreciated, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants