diff --git a/local-cli/server/util/attachHMRServer.js b/local-cli/server/util/attachHMRServer.js index c615f6e83..a223c1935 100644 --- a/local-cli/server/util/attachHMRServer.js +++ b/local-cli/server/util/attachHMRServer.js @@ -8,10 +8,12 @@ */ 'use strict'; -const {getInverseDependencies} = require('../../../packager/react-packager/src/node-haste'); const querystring = require('querystring'); const url = require('url'); +const {createEntry, print} = require('../../../packager/react-packager/src/Logger'); +const {getInverseDependencies} = require('../../../packager/react-packager/src/node-haste'); + const blacklist = [ 'Libraries/Utilities/HMRClient.js', ]; @@ -112,9 +114,9 @@ function attachHMRServer({httpServer, path, packagerServer}) { path: path, }); - console.log('[Hot Module Replacement] Server listening on', path); + print(createEntry(`HMR Server listening on ${path}`)); wss.on('connection', ws => { - console.log('[Hot Module Replacement] Client connected'); + print(createEntry('HMR Client connected')); const params = querystring.parse(url.parse(ws.upgradeReq.url).query); getDependencies(params.platform, params.bundleEntry) @@ -138,9 +140,7 @@ function attachHMRServer({httpServer, path, packagerServer}) { if (!client) { return; } - console.log( - `[Hot Module Replacement] File change detected (${time()})` - ); + print(createEntry('HMR Server detected file change')); const blacklisted = blacklist.find(blacklistedPath => filename.indexOf(blacklistedPath) !== -1 @@ -297,10 +297,7 @@ function attachHMRServer({httpServer, path, packagerServer}) { return; } - console.log( - '[Hot Module Replacement] Sending HMR update to client (' + - time() + ')' - ); + print(createEntry('HMR Server sending update to client')); client.ws.send(update); }); }, @@ -336,9 +333,4 @@ function arrayEquals(arrayA, arrayB) { ); } -function time() { - const date = new Date(); - return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}:${date.getMilliseconds()}`; -} - module.exports = attachHMRServer;