Skip to content

cli/praefect: Fix logging setup for client-side subcommands

Patrick Steinhardt requested to merge pks-log-refactor-praefect-commands into master

Many of the Praefect subcommands do not set up the logger, but immediately request them by calling log.Default(). This has multiple consequences:

- The log level is fixed at "info" level, which is potentially quite
  noisy.

- The gRPC logger isn't replaced properly, which has the consequence
  that the logger is overly verbose. Furthermore, we do not pay
  attention to the "GRPC_GO_LOG_SEVERITY_LEVEL" environment variable
  as we should be doing.

- The logger will print its output to standard output. This breaks
  the ability to consume the output of some commands whose output is
  intended to be machine-parsable.

Fix these issues by calling log.Configure() instead of log.Default() such that the logging infrastructure is getting properly initialized. Note that we don't use the configuration to set up the log format and level. This is intentional, because changing the server's configuration should not influence how clients perform logs.

In any case, the loggers are configured to output to standard error instead of standard output to fix (3). Furthermore, the verbosity of the logger is decreased to "error" level to address (1) and (2).

We could either add client-specific logging configuration to Praefect's configuration or alternatively add switches to the commands to configure logging ad-hoc. For the time being though we just care about fixing the above issues, so this is left for a later point in time if we see that there is indeed demand for such flexibility.

Merge request reports