-
-
Notifications
You must be signed in to change notification settings - Fork 4
Improve output format #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit has two effects: - arduino-cli init command logs are masked out. - arduino-cli upload logs are logged only if logrus was already enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I read the changes up to cli/thing/list.go
and stopped there because I noticed one main issue: we need to define clearly what we want on stderr and what on stdout and rework the feedback/logs.
We can't just move everything that precedently was printed to stdout to logs, in this way we will stop giving useful feedbacks to users and litter logs with unuseful messages.
Not printing anything to stdout in case of success could be fine if we decide to commit to a "quiet on success/verbose on error" behavior, but in this case we need to be coherent with it on all commands.
On the other hand, stderr (logs) should be used only to print information that could be useful for debugging purposes, because one does not reach for them unless there's some problem.
Update: check below. I missed an important detail about logs not being printed to stderr if the -v
is not provided. In our case it makes sense to have detailed logs of what happens.
@glumia
Yes, this was my goal. In this way the user can save the output of the commands into a file (when it makes sense).
Have I not been coherent with it on all commands? |
Yes! Sorry I got confused by the default behaviour of discarding logs and of Your reasoning makes perfectly sense 👍 As we were talking about in our call we need to just to remove logs when there's already the output of feedbacks and to standardize the formatting of results as |
Allows users to choose an output format between text and json. Writes to stdout (through fmt.Print..) have been replaced into writes to a logger. If the verbose flag -v is passed to the command line, then the logger will be enabled. Otherwise, all the logs messages will be discarded. These changes allow users to save results in files. For example, with the following command, a device is provisioned and its properties are written into a json file: ./iot-cloud-cli device create --format json --name <deviceName> > deviceName.json * Replace fmt print into log info * Distinguish board from device * Improve device format output * Fix log infof * Improve logs of arduino-cli This commit has two effects: - arduino-cli init command logs are masked out. - arduino-cli upload logs are logged only if logrus was already enabled. * Fix log msg * Update go mod * Improve thing output format * Refactor thing output format * Fix device iot client * Improve errors: use stderr and error codes * cli package: don't return error * Remove unreachable code * Improve log initialization * Remove duplication of info messages * Add arduino-cli source to upload logs * Return consistent output
Allows users to choose an output format between text and json. Writes to stdout (through fmt.Print..) have been replaced into writes to a logger. If the verbose flag -v is passed to the command line, then the logger will be enabled. Otherwise, all the logs messages will be discarded. These changes allow users to save results in files. For example, with the following command, a device is provisioned and its properties are written into a json file: ./iot-cloud-cli device create --format json --name <deviceName> > deviceName.json * Replace fmt print into log info * Distinguish board from device * Improve device format output * Fix log infof * Improve logs of arduino-cli This commit has two effects: - arduino-cli init command logs are masked out. - arduino-cli upload logs are logged only if logrus was already enabled. * Fix log msg * Update go mod * Improve thing output format * Refactor thing output format * Fix device iot client * Improve errors: use stderr and error codes * cli package: don't return error * Remove unreachable code * Improve log initialization * Remove duplication of info messages * Add arduino-cli source to upload logs * Return consistent output
Motivation
text
andjson
-v
is passed to the command line, then the logger will be enabled. Otherwise, all the logs messages will be discarded.These changes allow users to save results in files. For example, with the following command, a device is provisioned and its properties are written into a json file:
./iot-cloud-cli device create --format json --name <deviceName> > deviceName.json
Change description
Additional Notes
Reviewer checklist
main
.CONTRIBUTING.md
) and are well formatted.