Skip to content

Allow disabling logs SWC #3164

@RWOverdijk

Description

@RWOverdijk

Piping output from one command to another is a thing people who work on the terminal a lot do a lot. That's why almost every command has a toggle to control the output. Some call it verbosity (ssh for example, -v, -vv, -vvv etc), others log levels. Npm uses --silent for some reason, but it's there. The simplest example I can think of is stuff like the jq command, which will fail if the input is not proper json. So since > SWC Running... is not proper json, it will fail.

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I am using swc, which is great because everything is super fast. But it gets in the way when working on CLI commands, where I need the output of my command to pipe to another command. But it keeps logging "> SWC Running..." and I don't know how to make that stop without using NO_COLOR=1 and grep -v to exclude it myself.

TL;DR;

After locating the source of this log I found this line: https://github.com/nestjs/nest-cli/blob/master/lib/compiler/swc/swc-compiler.ts#L159

I would like clean output from the cli when developing, and the console.log is currently preventing that.

Describe the solution you'd like

Maybe the lib can listen to --silent, or LOG_LEVEL or any of the other conventions available.

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

I need the output of my command to pipe to another command.

Additional

ETA: I can work around this with grep, but realistically I don't think I'd have to. I'm unaware of the conventions for the cli codebase at this point, so if someone could point me in the right direction (maybe other places where we do listen to log levels) I could make a PR.
ETA 2: This is not really a bug. Not really a feature. So I didn't know where to put it. I chose feature because technically nothing is broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions