diff --git a/package-lock.json b/package-lock.json index fbe3a5f..ae411ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7314,6 +7314,12 @@ "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", "dev": true }, + "microee": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/microee/-/microee-0.0.6.tgz", + "integrity": "sha1-oSvbAQNoHosSapsHHrpMRnx4//4=", + "dev": true + }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -7438,6 +7444,15 @@ } } }, + "minilog": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/minilog/-/minilog-3.1.0.tgz", + "integrity": "sha1-0tDxiHyjY9Gs8OqG1cTfKTs/tnU=", + "dev": true, + "requires": { + "microee": "0.0.6" + } + }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", diff --git a/package.json b/package.json index 9536b28..85c6cbd 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "intl": "1.2.5", "lodash.bindall": "^4.4.0", "lodash.defaultsdeep": "^4.6.1", + "minilog": "^3.1.0", "mkdirp": "^1.0.4", "nets": "^3.2.0", "react": "16.2.0", diff --git a/src/common/log.js b/src/common/log.js new file mode 100644 index 0000000..ac12ba9 --- /dev/null +++ b/src/common/log.js @@ -0,0 +1,12 @@ +import minilog from 'minilog'; +minilog.enable(); + +const namespace = (() => { + switch (process.type) { + case 'browser': return 'main'; + case 'renderer': return 'web'; + default: return process.type; // probably 'worker' for a web worker + } +})(); + +export default minilog(`app-${namespace}`); diff --git a/src/main/index.js b/src/main/index.js index 51b02f3..6b20bbe 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -6,6 +6,7 @@ import {URL} from 'url'; import {getFilterForExtension} from './FileFilters'; import telemetry from './ScratchDesktopTelemetry'; import MacOSMenu from './MacOSMenu'; +import log from '../common/log.js'; telemetry.appWasOpened(); @@ -290,10 +291,8 @@ app.on('ready', () => { // WARNING: depending on a lot of things including the version of Electron `installExtension` might // return a promise that never resolves, especially if the extension is already installed. installExtension(extension).then( - // eslint-disable-next-line no-console - extensionName => console.log(`Installed dev extension: ${extensionName}`), - // eslint-disable-next-line no-console - errorMessage => console.error(`Error installing dev extension: ${errorMessage}`) + extensionName => log(`Installed dev extension: ${extensionName}`), + errorMessage => log.error(`Error installing dev extension: ${errorMessage}`) ); } });