openfaas / of-watchdog

Reverse proxy for STDIO and HTTP microservices
MIT License
259 stars 115 forks source link

When prefix_logs="false" is set, % signs logged by the function are interpreted as fmt.Printf verbs #132

Closed jcollie closed 2 years ago

jcollie commented 2 years ago

If you set the environment variable prefix_logs to false, % signs are interpreted by of-watchdog as fmt.Printf verbs.

Expected Behaviour

% signs should not be interpreted

Current Behaviour

If your function logs "%s", of-watchdog substitutes "%!s(MISSING)"

Possible Solution

Don't use fmt.Printf() to log data from the function.

Steps to Reproduce (for bugs)

  1. Create a function that has ENV prefix_logs="false"
  2. Deploy that function
  3. Log "%s" from your function.

Context

Your Environment

LucasRoesler commented 2 years ago

I think this makes sense and should be a relatively small change to https://github.com/openfaas/of-watchdog/blob/a0289419078824f0a070860f84a6b383eb4f2169/executor/logging.go

@jcollie would you be willing to open a Pull Request?

alexellis commented 2 years ago

Thanks for the issue and PR. Does this also affect the classic watchdog?

jcollie commented 2 years ago

Does this also affect the classic watchdog?

Not from what I saw, but I've never personally used the classic watchdog and I only spent a few minutes looking at the code.