vivliostyle / vivliostyle-cli

⚒ Supercharge command-line publication workflow.
https://docs.vivliostyle.org/#/vivliostyle-cli
GNU Affero General Public License v3.0
158 stars 22 forks source link

Incorrect stdout / stderr use #503

Open anghenfil opened 1 month ago

anghenfil commented 1 month ago

Hey,

currently vivliostyle-cli logs to stderr, even if the built was successfully:

stdout: "\ndata/main.pdf has been created.\n"

stderr: "- Collecting build config\nℹ Launching build environment\n(node:13) [DEP0040] DeprecationWarning: Thepunycodemodule is deprecated. Please use a userland alternative instead.\n(Usenode --trace-deprecation ...to show where the warning was created)\nℹ Building pages\nℹ Building PDF\nℹ Processing PDF\n🎉 Built successfully.\n"

It would be nice to only use stderr on failed builts, so that the vivliostyle-cli output can be parsed more easily.

Thanks! anghenfil

spring-raining commented 4 weeks ago

Hi @anghenfil, I found an option in the stream library used by vivliostyle-cli that can change this behavior. Adjusting this setting will resolve the issue. https://github.com/sindresorhus/ora?tab=readme-ov-file#stream

However, it is doubtful whether this setting should be used. The author of this library intentionally chose stderr as the default setting.

https://github.com/sindresorhus/ora/issues/85 The reason it's stderr is so that it will not interfere with normal output. Most other spinners use stderr too.

Despite its name, stderr is sometimes used for diagnostic messages like build progress, not just error messages. In my personal opinion, it is preferable to follow convention and use stderr. If you find the output annoying, please consider using the --log-level silent option.