kptdev / kpt

Automate Kubernetes Configuration Editing
https://kpt.dev
Apache License 2.0
1.69k stars 227 forks source link

Provide better logging utility in Functions SDK/libraries #1060

Open frankfarzan opened 3 years ago

frankfarzan commented 3 years ago

A problem that function developers run into: Emitting a debug log message to stdout. Because stdout is used for machine-to-machine protocol [1], it leads to cryptic failures from kpt fn. In Typescript, we actually override console.log to write to stderr, but we need a more uniform solution across different languages.

Consider:

  1. Introduce logger utilities in the libraries as the recommended approach to debug logging
  2. Improve the error message when the developer accidentally writes to stdout when do they don't use the logging utility provided.

[1] https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md

mikebz commented 3 years ago

@mengqiy feature to keep in mind for when you get to the SDK part of the function work.