[Bug] Print to stderr instead of using a logger for warnings/errors
In general, CLIs are not expected to produce logging output: they take in stdin and command line args, and output stdout and stderr. Our CLI does have at least one exception: we start a server with start dev. However, warnings and errors from short "transactional" commands should just be printed to stderr as plain natural language, without timestamps or other metadata.
One example of a current violation is
$ temporal operator namespace create default
time=2024-05-17T17:42:01.766 level=WARN msg="Passing the namespace as an argument is now deprecated; please switch to using -n instead"
Other examples of incorrect logging behavior include:
Here, an invalid update request was made. The CLI should print the error message without formatting it as a log message.
$ /opt/homebrew/bin/temporal workflow update --workflow-id doesnotexist --name update1
time=2024-08-27T09:47:51.644 level=ERROR msg="unable to update workflow: sql: no rows in result set"
Here, ctrl-c on a CLI should just exit with non-zero shell process exit status. It’s not normal for a CLI to produce an ERROR-level log message on ctrl-c
$ /opt/homebrew/bin/temporal workflow update --workflow-id wid --name update1
^Ctime=2024-08-27T09:44:55.093 level=ERROR msg="program interrupted"
It's just the formatting as a log message that's wrong; the text does go to stderr and the process exit code is 1 as expected.