tiup icon indicating copy to clipboard operation
tiup copied to clipboard

Refactor (console & log) output framework

Open AstroProfundis opened this issue 4 years ago • 0 comments

Feature Request

Is your feature request related to a problem? Please describe:

At the moment, we use several different packages to output information (both to console and to audit log files), this makes it hard to maintain and change if we need to update the TUI.

Describe the feature you'd like:

Sort out all outputs we use now and migrate them to one, unified output framework. I'd prefer to refactor pkg/logger to a wrapped zap logger, and all outputs are ported to use the customized logger instead of pure zap logger nor fmt.

The refactor work itself should NOT change any current TUI much (except necessary minor adjustments), we'll do that in other PRs, to avoid this work being too complex.

And be noted that changing audit log format is critical as it may broke the replay function.

Teachability, Documentation, Adoption, Migration Strategy:

Most of the codes related are in cluster and dm, and many many codes are using fmt to format console outputs. And we need to make sure things don't mess up when the messages has colored string in them.

I'd like to make pkg/logger the all-in-one output gateway of all components, and when the command is called, a multi target logger is initialized to output messages both to audit log and to console. They may be in different format (e.g., write JSON to audit log, and write formatted text to console), and the log level could be customized.

More details should be added once someone is willing to work on this and start to dig into the code.

AstroProfundis avatar Mar 15 '21 06:03 AstroProfundis