tapioca
tapioca copied to clipboard
Allow control over Thor's output
Addresses https://github.com/Shopify/team-ruby-dx/issues/1297
See lib/tapioca/logging.rb for the important parts.
Notes:
- We might want to introduce a RuboCop cop to prevent accidental use of
puts,say,say_erroretc. - There are still some places where the output is generated from within Thor, e.g.
create_fileandremove_file. I'm settingverbose: falseifTAPIOCA_DEVELOPMENTis set, but this isn't ideal. - There were a couple of places in the tests where the whitespace had to change, need to look into why.
- There is a type failure for argument forwarding (
...) that I need still address. - It would be nice if the tests could help us validate that we are always outputting to the logger and never directly to stdout, but that could be tricky.
Here is an example of the output written to the logs:
# Logfile created on 2024-10-08 12:54:33 -0400 by logger.rb/v1.6.1
I, [2024-10-08T12:54:33.421152 #10336] INFO -- : Removing RBI files of gems that have been removed:
I, [2024-10-08T12:54:33.422190 #10336] INFO -- : Nothing to do.
I, [2024-10-08T12:54:33.422234 #10336] INFO -- : Generating RBI files of gems that are added or updated:
I, [2024-10-08T12:54:33.422327 #10336] INFO -- : Nothing to do.
I, [2024-10-08T12:54:33.422427 #10336] INFO -- : Checking generated RBI files...
I, [2024-10-08T12:54:33.805008 #10336] INFO -- : Done
I, [2024-10-08T12:54:33.805374 #10336] INFO -- : No errors found
I, [2024-10-08T12:54:33.805389 #10336] INFO -- : All operations performed in working directory.
I, [2024-10-08T12:54:33.805397 #10336] INFO -- : Please review changes and commit them.