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

Add log statements for every request #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer cancel()

logFrameHeader(r)
log.Println("Request started")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think log.Println flushes, is this a problem? (I can see it might be, if the customer's trying to figure out why there code isn't running, but maybe it's out of scope for this change?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to flush, I think the problem was in Python fdk iirc.


h.handler.Serve(ctx, r.Body, &resp)

Expand All @@ -60,6 +61,8 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// copy response from user back up now with headers in place...
io.Copy(w, buf)

log.Println("Request completed")

// XXX(reed): handle streaming, we have to intercept headers but not necessarily body (ie no buffer)
}

Expand Down
2 changes: 2 additions & 0 deletions images/init/boilerplate/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"

fdk "github.com/fnproject/fdk-go"
)
Expand All @@ -25,5 +26,6 @@ func myHandler(ctx context.Context, in io.Reader, out io.Writer) {
}{
Msg: fmt.Sprintf("Hello %s", p.Name),
}
log.Print("Inside Go Hello World function")
json.NewEncoder(out).Encode(&msg)
}