~mzhang/garbage#8: 
Please don't use ANSI escape sequences when output is not a TTY

In short: garbage shouldn't attempt to colourize output to standard output or standard error when the file desciptor is not a TTY:

$ date > test.txt
$ garbage put -vv test.txt >test.log 2>&2  # neither stdout, nor stderr, is a tty now
$ cat test.log
?[2m2022-11-02T10:52:19.415654Z?[0m ?[32m INFO?[0m ?[2mgarbage::ops::put?[0m?[2m:?[0m Chosen strategy. ?[3mpath?[0m?[2m=?[0m"test.txt" ?[3mstrategy?[0m?[2m=?[0mMoveTo(TrashDir { path: "/tmp/.Trash-1000" })
?[2m2022-11-02T10:52:19.415861Z?[0m ?[32m INFO?[0m ?[1mtrash_dir?[0m?[1m{?[0mTrashDir { path: "/tmp/.Trash-1000" }?[1m}?[0m?[2m:?[0m ?[2mgarbage::ops::put::strategy?[0m?[2m:?[0m ?[3mpath_to_trashed_file?[0m?[2m=?[0m"/tmp/.Trash-1000/files/1667386339415.test.txt"
?[2m2022-11-02T10:52:19.415888Z?[0m ?[32m INFO?[0m ?[1mtrash_dir?[0m?[1m{?[0mTrashDir { path: "/tmp/.Trash-1000" }?[1m}?[0m?[2m:?[0m ?[2mgarbage::ops::put::strategy?[0m?[2m:?[0m ?[3mpath_to_trash_info?[0m?[2m=?[0m"/tmp/.Trash-1000/info/1667386339415.test.txt.trashinfo"
?[2m2022-11-02T10:52:19.415980Z?[0m ?[32m INFO?[0m ?[1mtrash_dir?[0m?[1m{?[0mTrashDir { path: "/tmp/.Trash-1000" }?[1m}?[0m?[2m:?[0m ?[2mgarbage::ops::put::strategy?[0m?[2m:?[0m Trash info: TrashInfo { path: "/tmp/test/test.txt", deletion_date: 2022-11-02T11:52:19.415758413+01:00, deleted_path: "/tmp/.Trash-1000/files/1667386339415.test.txt", info_path: "/tmp/.Trash-1000/info/1667386339415.test.txt.trashinfo" }
?[2m2022-11-02T10:52:19.416017Z?[0m ?[32m INFO?[0m ?[1mtrash_dir?[0m?[1m{?[0mTrashDir { path: "/tmp/.Trash-1000" }?[1m}?[0m?[2m:?[0m ?[2mgarbage::ops::put::strategy?[0m?[2m:?[0m Renaming file into trash directory. ?[3mfrom?[0m?[2m=?[0m"/tmp/test/test.txt" ?[3mto?[0m?[2m=?[0m"/tmp/.Trash-1000/files/1667386339415.test.txt" ?[3mis_symlink?[0m?[2m=?[0mfalse

Output should have looked like this:

$ cat test.log
2022-11-02T10:52:19.415654Z  INFO garbage::ops::put: Chosen strategy. path="test.txt" strategy=MoveTo(TrashDir { path: "/tmp/.Trash-1000" })
2022-11-02T10:52:19.415861Z  INFO trash_dir{TrashDir { path: "/tmp/.Trash-1000" }}: garbage::ops::put::strategy: path_to_trashed_file="/tmp/.Trash-1000/files/1667386339415.test.txt"
2022-11-02T10:52:19.415888Z  INFO trash_dir{TrashDir { path: "/tmp/.Trash-1000" }}: garbage::ops::put::strategy: path_to_trash_info="/tmp/.Trash-1000/info/1667386339415.test.txt.trashinfo"
2022-11-02T10:52:19.415980Z  INFO trash_dir{TrashDir { path: "/tmp/.Trash-1000" }}: garbage::ops::put::strategy: Trash info: TrashInfo { path: "/tmp/test/test.txt", deletion_date: 2022-11-02T11:52:19.415758413+01:00, deleted_path: "/tmp/.Trash-1000/files/1667386339415.test.txt", info_path: "/tmp/.Trash-1000/info/1667386339415.test.txt.trashinfo" }
2022-11-02T10:52:19.416017Z  INFO trash_dir{TrashDir { path: "/tmp/.Trash-1000" }}: garbage::ops::put::strategy: Renaming file into trash directory. from="/tmp/test/test.txt" to="/tmp/.Trash-1000/files/1667386339415.test.txt" is_symlink=false

Thanks.

Status
RESOLVED FIXED
Submitter
~kas
Assigned to
Submitted
2 years ago
Updated
2 years ago
Labels
No labels applied.

~mzhang REPORTED FIXED 2 years ago

Looks like tracing-subscriber doesn't have a way to do this automatically. I've implemented the quick fix in df4c502, but will use their built in way later when upstream adds the feature

~kas 2 years ago

Thank you so much!

Register here or Log in to comment, or comment via email.