forge icon indicating copy to clipboard operation
forge copied to clipboard

Support simplified output for logging

Open toonn opened this issue 3 years ago • 2 comments

Pre-flight checklist

  • [X] I have read the contribution documentation for this project.
  • [X] I agree to follow the code of conduct that this project uses.
  • [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

When logging output to a file the throbber isn't overwritten but appended:

⠋ Compiling Main Process Code⠙ Preparing to Package Application for arch: x64⠙ Compiling Main Process Code⠹ Preparing to Package Application for arch: x64⠹ Compiling Main Process Code⠸ Preparing to Package Application for arch: x64⠸ Compili
ng Main Process Code⠼ Preparing to Package Application for arch: x64⠼ Compiling Main Process Code⠴ Preparing to Package Application for arch: x64⠴ Compiling Mai
n Process Code⠦ Preparing to Package Application for arch: x64⠦ Compiling Main Process Code⠧ Preparing to Package Application for arch: x64⠧ Compiling Main Proc
ess Code⠇ Preparing to Package Application for arch: x64⠇ Compiling Main Process Code⠏ Preparing to Package Application for arch: x64⠏ Compiling Main Process Co
de⠋ Preparing to Package Application for arch: x64⠋ Compiling Main Process Code⠙ Preparing to Package Application for arch: x64⠙ Compiling Main Process Code⠹ Preparing to Package Application for arch: x64⠹ Compiling Main Process Code⠸ Preparing to Package Application for arch: x64⠸ Compiling Main Process Code⠼ Preparin
g to Package Application for arch: x64⠼ Compiling Main Process Code⠴ Preparing to Package Application for arch: x64⠴ Compiling Main Process Code⠦ Preparing to P
ackage Application for arch: x64⠦ Compiling Main Process Code⠧ Preparing to Package Application for arch: x64⠧ Compiling Main Process Code⠇ Preparing to Package
 Application for arch: x64

Proposed solution

Provide a flag that suppresses the throbber animation.

Alternatives considered

Many command line utilities try to detect whether they're writing to a TTY to toggle behavior automatically. Like how ls suppresses coloring when you pipe to less. Ideally there would still be a way to force output format when you want to.

Additional information

No response

toonn avatar Sep 22 '22 10:09 toonn

Many command line utilities try to detect whether they're writing to a TTY to toggle behavior automatically.

The ora docs mention that this should happen automatically 🤔

If [the isEnabled flag] is not specified, the spinner will be enabled if the stream is being run inside a TTY context (not spawned or piped) and/or not in a CI environment.

We don't use that flag in Forge's code, either.

erickzhao avatar Oct 08 '22 00:10 erickzhao

Could it be due to the ora version? The yarn.lock has ora versions 5.x and 6.0.0.

toonn avatar Oct 08 '22 12:10 toonn

Update: we're currently in the process of replacing Ora with listr2 as well. Not sure what the implications are for this issue but we'll revisit!

erickzhao avatar Nov 02 '22 15:11 erickzhao

Piping listr2 output to a file works as expected, closing this out as we've already landed listr2 support for start/init and package et. al is on the way in #3043

MarshallOfSound avatar Nov 02 '22 19:11 MarshallOfSound