diff --git a/.vscode/launch.json b/.vscode/launch.json index d993f2622cf5..65ac14a02553 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -234,7 +234,7 @@ "--ui=tdd", "--recursive", "--colors", - //"--grep", "", + //"--grep", "", "--timeout=300000" ], "env": { @@ -243,7 +243,7 @@ // Remove 'X' to turn on all logging in the debug output "XVSC_PYTHON_FORCE_LOGGING": "1", // Remove `X` prefix and update path to test with real python interpreter (for DS functional tests). - "XCI_PYTHON_PATH": "" + "XCI_PYTHON_PATH": "", }, "outFiles": [ "${workspaceFolder}/out/**/*.js" diff --git a/build/ci/templates/globals.yml b/build/ci/templates/globals.yml index 653f763266ac..993d41b98d18 100644 --- a/build/ci/templates/globals.yml +++ b/build/ci/templates/globals.yml @@ -6,6 +6,7 @@ variables: MOCHA_REPORTER_JUNIT: true # Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter). VSC_PYTHON_FORCE_LOGGING: true # Enable this to turn on console output for the logger VSC_PYTHON_LOG_FILE: '$(Build.ArtifactStagingDirectory)/pvsc.log' + VSC_PYTHON_WEBVIEW_LOG_FILE: '$(Build.ArtifactStagingDirectory)/pvsc_webview.log' CI_BRANCH_NAME: ${Build.SourceBranchName} npm_config_cache: $(Pipeline.Workspace)/.npm vmImageMacOS: 'macOS-10.15' diff --git a/build/webpack/webpack.datascience-ui.config.builder.js b/build/webpack/webpack.datascience-ui.config.builder.js index 928db7271cd9..8535b129fc78 100644 --- a/build/webpack/webpack.datascience-ui.config.builder.js +++ b/build/webpack/webpack.datascience-ui.config.builder.js @@ -190,6 +190,7 @@ function buildConfiguration(isNotebook) { }), ...getPlugins(isNotebook) ], + externals: ['log4js'], resolve: { // Add '.ts' and '.tsx' as resolvable extensions. extensions: ['.ts', '.tsx', '.js', '.json', '.svg'] diff --git a/gulpfile.js b/gulpfile.js index 66bed78babbd..1b00f5043b01 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -274,7 +274,9 @@ function getAllowedWarningsForWebPack(buildConfig) { 'WARNING in ./node_modules/ws/lib/validation.js', 'WARNING in ./node_modules/@jupyterlab/services/node_modules/ws/lib/buffer-util.js', 'WARNING in ./node_modules/@jupyterlab/services/node_modules/ws/lib/validation.js', - 'WARNING in ./node_modules/any-promise/register.js' + 'WARNING in ./node_modules/any-promise/register.js', + 'WARNING in ./node_modules/log4js/lib/appenders/index.js', + 'WARNING in ./node_modules/log4js/lib/clustering.js' ]; case 'extension': return [ diff --git a/package-lock.json b/package-lock.json index 0018b952fe69..bcd06599a795 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6639,6 +6639,11 @@ } } }, + "date-format": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-3.0.0.tgz", + "integrity": "sha512-eyTcpKOcamdhWJXj56DpQMo1ylSQpcGtGKXcU0Tb97+K56/CF5amAqqqNj0+KvA0iw2ynxtHWFsPDSClCxe48w==" + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -8586,6 +8591,11 @@ } } }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==" + }, "flush-write-stream": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", @@ -12107,6 +12117,28 @@ "chalk": "^2.0.1" } }, + "log4js": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.1.2.tgz", + "integrity": "sha512-knS4Y30pC1e0n7rfx3VxcLOdBCsEo0o6/C7PVTGxdVK+5b1TYOSGQPn9FDcrhkoQBV29qwmA2mtkznPAQKnxQg==", + "requires": { + "date-format": "^3.0.0", + "debug": "^4.1.1", + "flatted": "^2.0.1", + "rfdc": "^1.1.4", + "streamroller": "^2.2.3" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + } + } + }, "logform": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/logform/-/logform-2.1.2.tgz", @@ -16574,6 +16606,11 @@ "wipe-webpack-cache": "^2.1.0" } }, + "rfdc": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz", + "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==" + }, "rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -17800,6 +17837,41 @@ "integrity": "sha1-l+mNj6TRBdYqJpHR3AfoINuN/E8=", "dev": true }, + "streamroller": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-2.2.3.tgz", + "integrity": "sha512-AegmvQsscTRhHVO46PhCDerjIpxi7E+d2GxgUDu+nzw/HuLnUdxHWr6WQ+mVn/4iJgMKKFFdiUwFcFRDvcjCtw==", + "requires": { + "date-format": "^2.1.0", + "debug": "^4.1.1", + "fs-extra": "^8.1.0" + }, + "dependencies": { + "date-format": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz", + "integrity": "sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA==" + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + } + } + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", diff --git a/package.datascience-ui.dependencies.json b/package.datascience-ui.dependencies.json index 7eba4d7fb8cf..b03b9f49ccb4 100644 --- a/package.datascience-ui.dependencies.json +++ b/package.datascience-ui.dependencies.json @@ -1,247 +1,247 @@ [ - "@babel/runtime", - "@babel/runtime-corejs2", - "@emotion/hash", - "@emotion/memoize", - "@emotion/stylis", - "@emotion/unitless", - "@loadable/component", - "@mapbox/polylabel", - "@nteract/markdown", - "@nteract/mathjax", - "@nteract/octicons", - "@nteract/transform-dataresource", - "@nteract/transform-geojson", - "@nteract/transform-model-debug", - "@nteract/transform-plotly", - "@nteract/transform-vdom", - "@nteract/transform-vega", - "@nteract/transforms", - "@blueprintjs/core", - "@blueprintjs/icons", - "@blueprintjs/select", - "@icons/material", - "@nteract/styled-blueprintjsx", - "@nteract/vega-embed-v2", - "@nteract/vega-embed-v3", - "anser", - "ansi-regex", - "ansi-to-html", - "ansi-to-react", - "babel-polyfill", - "babel-runtime", - "bail", - "base16", - "bintrees", - "bootstrap-less", - "base64-js", - "create-react-context", - "character-entities-legacy", - "character-reference-invalid", - "classnames", - "clsx", - "collapse-white-space", - "create-emotion", - "css-loader", - "canvas", - "dom4", - "d3-array", - "d3-bboxCollide", - "d3-brush", - "d3-chord", - "d3-collection", - "d3-color", - "d3-contour", - "d3-dispatch", - "d3-drag", - "d3-ease", - "d3-force", - "d3-format", - "d3-glyphedge", - "d3-hexbin", - "d3-hierarchy", - "d3-interpolate", - "d3-path", - "d3-polygon", - "d3-quadtree", - "d3-sankey-circular", - "d3-scale", - "d3-selection", - "d3-shape", - "d3-time-format", - "d3-time", - "d3-timer", - "d3-transition", - "d3-voronoi", - "dom-helpers", - "d3-cloud", - "d3-delaunay", - "d3-dsv", - "d3-geo", - "d3-request", - "d3-scale-chromatic", - "d3", - "datalib", - "delaunator", - "define-properties", - "emotion", - "entities", - "escape-carriage", - "extend", - "fast-deep-equal", - "fast-plist", - "fast-json-stable-stringify", - "function-bind", - "gud", - "has", - "hoist-non-react-statics", - "inherits", - "invariant", - "is-alphabetical", - "is-alphanumerical", - "is-arguments", - "is-buffer", - "is-date-object", - "is-decimal", - "is-hexadecimal", - "is-plain-obj", - "is-regex", - "is-whitespace-character", - "is-word-character", - "ieee754", - "isarray", - "json2csv", - "json-stable-stringify", - "json-stringify-pretty-compact", - "jsonify", - "labella", - "leaflet", - "linear-layout-vector", - "lodash.curry", - "lodash.flow", - "lodash", - "lru-cache", - "martinez-polygon-clipping", - "markdown-escapes", - "material-colors", - "mdast-add-list-metadata", - "monaco-editor", - "monaco-editor-textmate", - "monaco-textmate", - "numeral", - "node-libs-browser", - "object-assign", - "object-is", - "object-keys", - "onigasm", - "popper.js", - "parse-entities", - "path-browserify", - "polygon-offset", - "plotly.js-dist", - "process", - "prop-types", - "pseudomap", - "pure-color", - "react-is", - "react-popper", - "react-transition-group", - "regexp.prototype.flags", - "regression", - "replace-ext", - "resize-observer-polyfill", - "react-annotation", - "react-base16-styling", - "react-color", - "react-data-grid", - "react-dom", - "react-hot-loader", - "react-json-tree", - "react-lifecycles-compat", - "react-markdown", - "react-redux", - "react-svg-pan-zoom", - "react-svgmt", - "react-table-hoc-fixed-columns", - "react-table", - "react-virtualized", - "react", - "reactcss", - "redux-logger", - "redux", - "remark-parse", - "repeat-string", - "roughjs-es5", - "scheduler", - "semiotic-mark", - "semiotic", - "setimmediate", - "slickgrid", - "state-toggle", - "string-hash", - "style-loader", - "styled-jsx", - "stylis-rule-sheet", - "svg-inline-react", - "svg-path-bounding-box", - "svgpath", - "semver", - "timers-browserify", - "tinycolor2", - "tinyqueue", - "transformation-matrix", - "trim-trailing-lines", - "trim", - "trough", - "topojson-client", - "tslib", - "unherit", - "unified", - "uniqid", - "unist-util-is", - "unist-util-remove-position", - "unist-util-stringify-position", - "unist-util-visit-parents", - "unist-util-visit", - "util", - "uuid", - "vfile-location", - "vfile-message", - "vfile", - "viz-annotation", - "vega-canvas", - "vega-crossfilter", - "vega-dataflow", - "vega-embed", - "vega-encode", - "vega-event-selector", - "vega-expression", - "vega-force", - "vega-functions", - "vega-geo", - "vega-hierarchy", - "vega-lite", - "vega-loader", - "vega-parser", - "vega-projection", - "vega-regression", - "vega-runtime", - "vega-scale", - "vega-scenegraph", - "vega-schema-url-parser", - "vega-selections", - "vega-statistics", - "vega-themes", - "vega-tooltip", - "vega-transforms", - "vega-util", - "vega-view-transforms", - "vega-view", - "vega-voronoi", - "vega-wordcloud", - "vega", - "warning", - "x-is-string", - "xtend", - "yallist" -] + "@babel/runtime", + "@babel/runtime-corejs2", + "@emotion/hash", + "@emotion/memoize", + "@emotion/stylis", + "@emotion/unitless", + "@loadable/component", + "@mapbox/polylabel", + "@nteract/markdown", + "@nteract/mathjax", + "@nteract/octicons", + "@nteract/transform-dataresource", + "@nteract/transform-geojson", + "@nteract/transform-model-debug", + "@nteract/transform-plotly", + "@nteract/transform-vdom", + "@nteract/transform-vega", + "@nteract/transforms", + "@blueprintjs/core", + "@blueprintjs/icons", + "@blueprintjs/select", + "@icons/material", + "@nteract/styled-blueprintjsx", + "@nteract/vega-embed-v2", + "@nteract/vega-embed-v3", + "anser", + "ansi-regex", + "ansi-to-html", + "ansi-to-react", + "babel-polyfill", + "babel-runtime", + "bail", + "base16", + "bintrees", + "bootstrap-less", + "base64-js", + "create-react-context", + "character-entities-legacy", + "character-reference-invalid", + "classnames", + "clsx", + "collapse-white-space", + "create-emotion", + "css-loader", + "canvas", + "dom4", + "d3-array", + "d3-bboxCollide", + "d3-brush", + "d3-chord", + "d3-collection", + "d3-color", + "d3-contour", + "d3-dispatch", + "d3-drag", + "d3-ease", + "d3-force", + "d3-format", + "d3-glyphedge", + "d3-hexbin", + "d3-hierarchy", + "d3-interpolate", + "d3-path", + "d3-polygon", + "d3-quadtree", + "d3-sankey-circular", + "d3-scale", + "d3-selection", + "d3-shape", + "d3-time-format", + "d3-time", + "d3-timer", + "d3-transition", + "d3-voronoi", + "dom-helpers", + "d3-cloud", + "d3-delaunay", + "d3-dsv", + "d3-geo", + "d3-request", + "d3-scale-chromatic", + "d3", + "datalib", + "delaunator", + "define-properties", + "emotion", + "entities", + "escape-carriage", + "extend", + "fast-deep-equal", + "fast-plist", + "fast-json-stable-stringify", + "function-bind", + "gud", + "has", + "hoist-non-react-statics", + "inherits", + "invariant", + "is-alphabetical", + "is-alphanumerical", + "is-arguments", + "is-buffer", + "is-date-object", + "is-decimal", + "is-hexadecimal", + "is-plain-obj", + "is-regex", + "is-whitespace-character", + "is-word-character", + "ieee754", + "isarray", + "json2csv", + "json-stable-stringify", + "json-stringify-pretty-compact", + "jsonify", + "labella", + "leaflet", + "linear-layout-vector", + "lodash.curry", + "lodash.flow", + "lodash", + "lru-cache", + "martinez-polygon-clipping", + "markdown-escapes", + "material-colors", + "mdast-add-list-metadata", + "monaco-editor", + "monaco-editor-textmate", + "monaco-textmate", + "numeral", + "node-libs-browser", + "object-assign", + "object-is", + "object-keys", + "onigasm", + "popper.js", + "parse-entities", + "path-browserify", + "polygon-offset", + "plotly.js-dist", + "process", + "prop-types", + "pseudomap", + "pure-color", + "react-is", + "react-popper", + "react-transition-group", + "regexp.prototype.flags", + "regression", + "replace-ext", + "resize-observer-polyfill", + "react-annotation", + "react-base16-styling", + "react-color", + "react-data-grid", + "react-dom", + "react-hot-loader", + "react-json-tree", + "react-lifecycles-compat", + "react-markdown", + "react-redux", + "react-svg-pan-zoom", + "react-svgmt", + "react-table-hoc-fixed-columns", + "react-table", + "react-virtualized", + "react", + "reactcss", + "redux-logger", + "redux", + "remark-parse", + "repeat-string", + "roughjs-es5", + "scheduler", + "semiotic-mark", + "semiotic", + "setimmediate", + "slickgrid", + "state-toggle", + "string-hash", + "style-loader", + "styled-jsx", + "stylis-rule-sheet", + "svg-inline-react", + "svg-path-bounding-box", + "svgpath", + "semver", + "timers-browserify", + "tinycolor2", + "tinyqueue", + "transformation-matrix", + "trim-trailing-lines", + "trim", + "trough", + "topojson-client", + "tslib", + "unherit", + "unified", + "uniqid", + "unist-util-is", + "unist-util-remove-position", + "unist-util-stringify-position", + "unist-util-visit-parents", + "unist-util-visit", + "util", + "uuid", + "vfile-location", + "vfile-message", + "vfile", + "viz-annotation", + "vega-canvas", + "vega-crossfilter", + "vega-dataflow", + "vega-embed", + "vega-encode", + "vega-event-selector", + "vega-expression", + "vega-force", + "vega-functions", + "vega-geo", + "vega-hierarchy", + "vega-lite", + "vega-loader", + "vega-parser", + "vega-projection", + "vega-regression", + "vega-runtime", + "vega-scale", + "vega-scenegraph", + "vega-schema-url-parser", + "vega-selections", + "vega-statistics", + "vega-themes", + "vega-tooltip", + "vega-transforms", + "vega-util", + "vega-view-transforms", + "vega-view", + "vega-voronoi", + "vega-wordcloud", + "vega", + "warning", + "x-is-string", + "xtend", + "yallist" +] \ No newline at end of file diff --git a/package.json b/package.json index bae543b1ba12..f92b72b3ffb9 100644 --- a/package.json +++ b/package.json @@ -1377,7 +1377,9 @@ "default": "127.0.0.1" } }, - "required": ["port"] + "required": [ + "port" + ] }, "listen": { "type": "object", @@ -1393,7 +1395,9 @@ "default": "127.0.0.1" } }, - "required": ["port"] + "required": [ + "port" + ] }, "port": { "type": "number", @@ -2918,6 +2922,7 @@ "koa-logger": "^3.2.1", "line-by-line": "^0.1.6", "lodash": "^4.17.15", + "log4js": "^6.1.2", "md5": "^2.2.1", "minimatch": "^3.0.4", "named-js-regexp": "^1.3.3", diff --git a/src/datascience-ui/interactive-common/redux/store.ts b/src/datascience-ui/interactive-common/redux/store.ts index 04a41739f9e8..e9475adc078a 100644 --- a/src/datascience-ui/interactive-common/redux/store.ts +++ b/src/datascience-ui/interactive-common/redux/store.ts @@ -2,8 +2,10 @@ // Licensed under the MIT License. 'use strict'; import * as fastDeepEqual from 'fast-deep-equal'; +import * as path from 'path'; import * as Redux from 'redux'; import { createLogger } from 'redux-logger'; +import { EXTENSION_ROOT_DIR } from '../../../client/constants'; import { Identifiers } from '../../../client/datascience/constants'; import { InteractiveWindowMessages } from '../../../client/datascience/interactive-common/interactiveWindowTypes'; import { MessageType } from '../../../client/datascience/interactive-common/synchronization'; @@ -114,6 +116,20 @@ function createSendInfoMiddleware(): Redux.Middleware<{}, IStore> { }; } +function createTestLogger() { + const logFileEnv = process.env.VSC_PYTHON_WEBVIEW_LOG_FILE; + if (logFileEnv) { + // tslint:disable-next-line: no-require-imports + const log4js = require('log4js') as typeof import('log4js'); + const logFilePath = path.isAbsolute(logFileEnv) ? logFileEnv : path.join(EXTENSION_ROOT_DIR, logFileEnv); + log4js.configure({ + appenders: { reduxLogger: { type: 'file', filename: logFilePath } }, + categories: { default: { appenders: ['reduxLogger'], level: 'debug' } } + }); + return log4js.getLogger(); + } +} + function createTestMiddleware(): Redux.Middleware<{}, IStore> { // Make sure all dynamic imports are loaded. const transformPromise = forceLoad(); @@ -243,7 +259,8 @@ function createMiddleWare(testMode: boolean): Redux.Middleware<{}, IStore>[] { return { ...action, payload: reduceLogMessage }; } return action; - } + }, + logger: testMode ? createTestLogger() : undefined }); // On CI we might want to disable logging, as its a big wall of text. // TO disable that add the variable `VSC_PYTHON_DS_NO_REDUX_LOGGING=1`