Overview
This is a proposal to update logger and fix error handling in general.
Origin
I have been using harbor CLI to manage my local registry for a while. So when I was trying to visit the audit logs of my registry using harbor logs, the process exited with a status code 1 without any proper logging or reason.

Then after some time I found that the registry hasn't been started using harbor health (That's my bad), but though there isn't any proper response from the tool. So I just started to test other commands and their sub-commands, where I get varied response and logging.
Surprisingly upon executing harbor user elevate, The program just panicked.

Also even the harbor user create just gets all the inputs and exits without proper logging, irrespective of the status of the registry.

More Context
When I was working on this #634, the logger didn't log anything, as the logrus logger didn't set the output writer properly.
This may be a quick fix, but there are lot of lines of code performing logging, scattered across files.
Additionally, the logrus logger library which is being used in the project, has been in maintenance mode for nearly 6 years. (ref)
Due to these, the errors neither handled properly nor being logged. And at some places, errors are simply ignored, which isn't a good practice. (example).
Proposal
With all the above considerations in mind, I suggest to,
- Use the Charm's
log library.
I suggest using the above lib, as the TUI is developed using Charm's components, styles and will be easy to set the theme across the CLI entirely
- Build a logger package using Cobra CLI's builtin
stdout & stderr writter.
- Or use of any other logger such as Zerolog, Zap.
And for errors, I would highly suggest to define an internal errors package listing and mapping all the possible errors, that the tool may encounter. Like how it is implemented properly in the Harbor and its go-client SDK itself. (example)
So request the maintainers and the community to go through this proposal and share your thoughts and recommendations in this issue thread.
cc: @bupd @Vad1mo @OrlinVasilev @qcserestipy @NucleoFusion
Overview
Origin
I have been using
harborCLI to manage my local registry for a while. So when I was trying to visit the audit logs of my registry usingharbor logs, the process exited with a status code 1 without any proper logging or reason.Then after some time I found that the registry hasn't been started using
harbor health(That's my bad), but though there isn't any proper response from the tool. So I just started to test other commands and their sub-commands, where I get varied response and logging.Surprisingly upon executing
harbor user elevate, The program just panicked.Also even the
harbor user createjust gets all the inputs and exits without proper logging, irrespective of the status of the registry.More Context
When I was working on this #634, the logger didn't log anything, as the logrus logger didn't set the output writer properly.
This may be a quick fix, but there are lot of lines of code performing logging, scattered across files.
Additionally, the logrus logger library which is being used in the project, has been in maintenance mode for nearly 6 years. (ref)
Due to these, the errors neither handled properly nor being logged. And at some places, errors are simply ignored, which isn't a good practice. (example).
Proposal
With all the above considerations in mind, I suggest to,
loglibrary.stdout&stderrwritter.And for errors, I would highly suggest to define an internal
errorspackage listing and mapping all the possible errors, that the tool may encounter. Like how it is implemented properly in the Harbor and itsgo-clientSDK itself. (example)So request the maintainers and the community to go through this proposal and share your thoughts and recommendations in this issue thread.
cc: @bupd @Vad1mo @OrlinVasilev @qcserestipy @NucleoFusion