Skip to content

migrate to built-in logger #2563

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

Closed
wants to merge 8 commits into from
Closed

migrate to built-in logger #2563

wants to merge 8 commits into from

Conversation

hiroppy
Copy link
Member

@hiroppy hiroppy commented May 2, 2020

DON'T MERGE but request maintainer's comments

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Yep

Motivation / Use-Case

We need to drop webpack-log because this package isn't under our management.
see https://www.npmjs.com/package/webpack-log

And webpack@4 supports infrastructureLogging system so I decided to migrate to it. See https://webpack.js.org/configuration/other-options/#infrastructurelogging.

Output

<i> [webpack-dev-server] Project is running at http://localhost:8080/
<i> [webpack-dev-server] webpack output is served from /
<i> [webpack-dev-server] Content not from webpack is served from /Users/hiroppy/webpack/webpack-dev-server

Dropped keys (CLI as well)

  • logLevel
  • quiet
  • info

Modified keys

  • clientLogLevel
    • deleted debug, trace, silent, and warning instead of none, warn and verbose

Breaking Changes

Yep

Additional Info

Currently, I don't know why but the CLI test of multi ports fails so I'm investigating it.

knagaitsev and others added 7 commits April 27, 2020 14:21
* chore(deps): upgrade chokidar

* chore(deps): switch to promise method without async for close

* chore(ci): remove node v6

* chore(deps): fix issue of closing watchers before middleware

* chore(deps): upgrade chokidar to v3.4.0
* chore(deps): upgrade deps

* style: run prettier

* test: update

* ci: remove Node@8

* test(cli): add windows support

* chore(deps): downgrade puppeteer

* chore(deps): downgrade some deps

* fix(hot): enable hot option as default (#2546)

BREAKING CHANGE: the `hot` option is `true` by default, the `hotOnly` option was removed in favor `{ hot: 'only' }`

* fix: remove lazy and filename options (#2544)

BREAKING CHANGE: `lazy` and `filename` options was removed
@codecov
Copy link

codecov bot commented May 2, 2020

Codecov Report

Merging #2563 into v4 will decrease coverage by 0.28%.
The diff coverage is 99.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v4    #2563      +/-   ##
==========================================
- Coverage   93.77%   93.49%   -0.29%     
==========================================
  Files          34       34              
  Lines        1333     1275      -58     
  Branches      381      354      -27     
==========================================
- Hits         1250     1192      -58     
  Misses         81       81              
  Partials        2        2              
Impacted Files Coverage Δ
lib/utils/createConfig.js 96.03% <ø> (-0.43%) ⬇️
lib/utils/status.js 90.00% <ø> (-1.31%) ⬇️
client-src/default/index.js 95.45% <92.85%> (+3.23%) ⬆️
client-src/default/overlay.js 97.01% <100.00%> (+0.04%) ⬆️
client-src/default/utils/createLogger.js 100.00% <100.00%> (ø)
client-src/default/utils/reloadApp.js 86.36% <100.00%> (-13.64%) ⬇️
lib/Server.js 96.73% <100.00%> (-0.06%) ⬇️
lib/servers/SockJSServer.js 93.75% <100.00%> (ø)
lib/utils/addEntries.js 100.00% <100.00%> (ø)
lib/utils/createLogger.js 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 375ab23...b6af4e9. Read the comment docs.

@@ -74,17 +74,12 @@ const options = {
default: true,
describe: 'Info',
},
quiet: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Respect to infrastructurelogging.level.

'client-log-level': {
type: 'string',
group: DISPLAY_GROUP,
default: 'info',
describe:
'Log level in the browser (trace, debug, info, warn, error or silent)',
'Log level in the browser (none, error, warn, info, log, verbose)',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've already talked about it and they should respect infrastructurelogging.level.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, in fact, client-log-level should respect infrastructurelogging.level? What do you think?

if (options.useWarningOverlay || options.useErrorOverlay) {
overlay.clear();
}
sendMessage('StillOk');
},
'log-level': function logLevel(level) {
const hotCtx = require.context('webpack/hot', false, /^\.\/log$/);
if (hotCtx.keys().indexOf('./log') !== -1) {
hotCtx('./log').setLogLevel(level);
Copy link
Member Author

@hiroppy hiroppy May 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but I think this is unnecessary. I've already checked that this log-level is applied to clientLogLevel which is from CLI flag.

done: false,
},
};
it('should use different random port when multiple instances are started on different processes', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails so I need to fix it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this test in the master branch is broken as well...

cp1:null cp2: 8080

Yes this test passes because null !== 8080 but we don't expect it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed this test.

@hiroppy hiroppy changed the title BREAKING CHANGE: migrate on built-in logger BREAKING CHANGE: migrate to built-in logger May 2, 2020
@hiroppy hiroppy force-pushed the feature/builtin-logger branch 3 times, most recently from 3252e64 to c2b23aa Compare May 2, 2020 15:29
@@ -38,13 +38,11 @@ if (!process.env.WEBPACK_DEV_SERVER) {
}

class Server {
constructor(compiler, options = {}, _log) {
constructor(compiler, options = {}, log) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remain log for users who want to inject a custom logger.

@hiroppy hiroppy force-pushed the feature/builtin-logger branch from c2b23aa to af1f64c Compare May 2, 2020 23:23
@hiroppy hiroppy force-pushed the feature/builtin-logger branch from af1f64c to b6af4e9 Compare May 3, 2020 00:15
@hiroppy hiroppy changed the title BREAKING CHANGE: migrate to built-in logger migrate to built-in logger May 12, 2020
@hiroppy hiroppy closed this May 19, 2020
@hiroppy hiroppy deleted the feature/builtin-logger branch May 19, 2020 11:28
@knagaitsev knagaitsev restored the feature/builtin-logger branch May 28, 2020 18:00
@alexander-akait alexander-akait deleted the feature/builtin-logger branch February 27, 2021 14:39
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 this pull request may close these issues.

4 participants