Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to remove logging in watch mode? #2019

Closed
BigMeat233 opened this issue Nov 2, 2020 · 16 comments · Fixed by #2144
Closed

[Question] How to remove logging in watch mode? #2019

BigMeat233 opened this issue Nov 2, 2020 · 16 comments · Fixed by #2144

Comments

@BigMeat233
Copy link

I find cli always printing message(ex: Compilation finished, watching files for updates) in v4.

But I only need the error message.

So how to close the success message in v4?

@BigMeat233 BigMeat233 changed the title How to remove logging in watch mode? [Question] How to remove logging in watch mode? Nov 2, 2020
@snitin315
Copy link
Member

I don't think you can.

@alexander-akait
Copy link
Member

Yes, no ability, why do you need this?

@piecyk
Copy link
Contributor

piecyk commented Nov 2, 2020

This will be possible when webpack-cli would use InfrastructureLogger for logging. Similar as webpack-dev-server v4 will.

There are two issues to use it in plugin

  1. webpack InfrastructureLogger is logging to stderr, that would be change from current stdout.
  2. InfrastructureLogger is created from compiler, how we should log before?

@BigMeat233
Copy link
Author

BigMeat233 commented Nov 3, 2020

@evilebottnawi Hello, there is my scenarios:

I use webpack-cli watch mode to build project automatically.

And I use a webpack plugin named friendly-errors-webpack-plugin to hide log message in building progress.

But the console always print '99% done plugins watchInfo[webpack-cli] Compilation finished [webpack-cli] watching files for updates...' when building success.

So, I want a way to remove this message.

@BigMeat233
Copy link
Author

BigMeat233 commented Nov 3, 2020

@piecyk Hello, I want a flag to open/close the logger in Line 288 and Line 340 of the file /webpack-cli.js.

And my webpack-cli version is 4.1.0

@rishabh3112
Copy link
Member

Seems to be a valid use-case to me. Many users may prefer to have a less verbose output in watch-mode.

@piecyk
Copy link
Contributor

piecyk commented Nov 3, 2020

@BigMeat233 output from webpack should be controlled by the level in infrastructureLogging

So you would configure it in webpack config via

infrastructureLogging: {
  level: "error"
},

https://webpack.js.org/api/logging

@BigMeat233
Copy link
Author

@piecyk Thanks for your anwser.

But I still can't hide the cli logging message in watch mode:

[webpack-cli] Compilation finished

[webpack-cli] watching files for updates...

@piecyk
Copy link
Contributor

piecyk commented Nov 3, 2020

@BigMeat233 because it's not implemented yet.

@alexander-akait
Copy link
Member

In theory we can respect infrastructureLogging from config, it should be not hard

@piecyk
Copy link
Contributor

piecyk commented Nov 3, 2020

@evilebottnawi yep i think that also, would go into this direction

master...piecyk:webpack-cli/infrastructure-logging

@piecyk
Copy link
Contributor

piecyk commented Nov 3, 2020

@evilebottnawi can you have a quick look at that branch https://github.com/piecyk/webpack-cli/tree/webpack-cli/infrastructure-logging, ping me if that is something we would like to merge, need to fix tests 🙈

@alexander-akait
Copy link
Member

Looks good, but I am afraid it is not solve the whole problem, we use logger out of plugin too, so I think right way to fix it, just read the infrastructureLogging option from config

@piecyk
Copy link
Contributor

piecyk commented Nov 4, 2020

Looks good, but I am afraid it is not solve the whole problem, we use logger out of plugin too, so I think right way to fix it, just read the infrastructureLogging option from config

Yes we do. Most cases we log errors and exit process so in that case tooling based on webpack will never reach them, like friendly-errors-webpack-plugin

At first started also with replacing utils/logger with require('webpack/lib/logging/runtime') and configuring it with infrastructureLogging from options. But this would make bigger breaking change, we would need to drop logger.raw etc.

So decided going simpler, for now we can switch to infrastructureLogging in WebpackCLIPlugin that handles output from webpack what 99% users wants.

@alexander-akait
Copy link
Member

Yep, anyway feel free to send a PR and we continue improvements in PR, code looks good

@piecyk
Copy link
Contributor

piecyk commented Nov 4, 2020

Ok, pushed a PR. Let's discuss there, i'm proposing there some changes to messages we log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants