From b51eac30bed0cae62ad5745dd5a4d8176be88d56 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 9 Apr 2020 19:19:46 +0200 Subject: [PATCH 01/14] ADD logLever preset property && filter lower lever log messages --- lib/client-logger/package.json | 4 +++- lib/client-logger/src/index.ts | 21 +++++++++++++------ lib/client-logger/src/typings.d.ts | 1 + lib/core/src/server/common/common-preset.js | 2 ++ .../server/manager/manager-webpack.config.js | 5 ++++- .../server/preview/iframe-webpack.config.js | 5 ++++- 6 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 lib/client-logger/src/typings.d.ts diff --git a/lib/client-logger/package.json b/lib/client-logger/package.json index 8d672258bac7..2fcf320f9481 100644 --- a/lib/client-logger/package.json +++ b/lib/client-logger/package.json @@ -28,7 +28,9 @@ "prepare": "node ../../scripts/prepare.js" }, "dependencies": { - "core-js": "^3.0.1" + "core-js": "^3.0.1", + "global": "^4.3.2", + "loglevel": "^1.6.7" }, "publishConfig": { "access": "public" diff --git a/lib/client-logger/src/index.ts b/lib/client-logger/src/index.ts index be814d8b8a76..6b1801055047 100644 --- a/lib/client-logger/src/index.ts +++ b/lib/client-logger/src/index.ts @@ -1,16 +1,25 @@ -const { console } = global; - -/* tslint:disable: no-console */ +import { window, LOGLEVEL } from 'global'; +import console from 'loglevel'; export const logger = { + trace: (message: any, ...rest: any[]): void => console.trace(message, ...rest), debug: (message: any, ...rest: any[]): void => console.debug(message, ...rest), - log: (message: any, ...rest: any[]): void => console.log(message, ...rest), + log: (message: any, ...rest: any[]): void => window.console.log(message, ...rest), info: (message: any, ...rest: any[]): void => console.info(message, ...rest), warn: (message: any, ...rest: any[]): void => console.warn(message, ...rest), error: (message: any, ...rest: any[]): void => console.error(message, ...rest), }; -export const pretty = (type: keyof typeof logger) => (...args: string[]) => { +if (LOGLEVEL) { + console.setLevel(LOGLEVEL); +} + +// eslint-disable-next-line no-underscore-dangle +window.__STORYBOOK_LOGGER = console; + +export const pretty = (type: 'trace' | 'debug' | 'info' | 'warn' | 'error') => ( + ...args: string[] +) => { const argArray = []; if (args.length) { @@ -36,8 +45,8 @@ export const pretty = (type: keyof typeof logger) => (...args: string[]) => { console[type].apply(console, argArray); }; +pretty.trace = pretty('trace'); pretty.debug = pretty('debug'); -pretty.log = pretty('log'); pretty.info = pretty('info'); pretty.warn = pretty('warn'); pretty.error = pretty('error'); diff --git a/lib/client-logger/src/typings.d.ts b/lib/client-logger/src/typings.d.ts new file mode 100644 index 000000000000..2f4eb9cf4fd9 --- /dev/null +++ b/lib/client-logger/src/typings.d.ts @@ -0,0 +1 @@ +declare module 'global'; diff --git a/lib/core/src/server/common/common-preset.js b/lib/core/src/server/common/common-preset.js index 222a9127a75a..0d52a6e80df1 100644 --- a/lib/core/src/server/common/common-preset.js +++ b/lib/core/src/server/common/common-preset.js @@ -9,3 +9,5 @@ export const babel = async (_, options) => { presets.apply('babelDefault', babelConfig(options), options) ); }; + +export const logLevel = () => 'info'; diff --git a/lib/core/src/server/manager/manager-webpack.config.js b/lib/core/src/server/manager/manager-webpack.config.js index a5251517eb9c..29d4ff3c36d8 100644 --- a/lib/core/src/server/manager/manager-webpack.config.js +++ b/lib/core/src/server/manager/manager-webpack.config.js @@ -21,7 +21,7 @@ import { resolvePathInStorybookCache } from '../utils/resolve-path-in-sb-cache'; const coreDirName = path.dirname(require.resolve('@storybook/core/package.json')); const context = path.join(coreDirName, '../../node_modules'); -export default ({ +export default async ({ configDir, configType, docsMode, @@ -32,8 +32,10 @@ export default ({ cache, previewUrl, versionCheck, + presets, }) => { const { raw, stringified } = loadEnv(); + const logLevel = await presets.apply('logLevel', []); const isProd = configType === 'PRODUCTION'; const refsTemplate = fse.readFileSync(path.join(__dirname, 'virtualModuleRef.template.js'), { encoding: 'utf8', @@ -78,6 +80,7 @@ export default ({ version, dlls: dll ? ['./sb_dll/storybook_ui_dll.js'] : [], globals: { + LOGLEVEL: JSON.stringify(logLevel), VERSIONCHECK: JSON.stringify(versionCheck), DOCS_MODE: docsMode, // global docs mode PREVIEW_URL: previewUrl, // global preview URL diff --git a/lib/core/src/server/preview/iframe-webpack.config.js b/lib/core/src/server/preview/iframe-webpack.config.js index 31be082b6252..eb49ebe3db33 100644 --- a/lib/core/src/server/preview/iframe-webpack.config.js +++ b/lib/core/src/server/preview/iframe-webpack.config.js @@ -39,6 +39,7 @@ export default async ({ presets, }) => { const dlls = await presets.apply('webpackDlls', []); + const logLevel = await presets.apply('logLevel', []); const { raw, stringified } = loadEnv({ production: true }); const babelLoader = createBabelLoader(babelOptions); const isProd = configType === 'PRODUCTION'; @@ -107,7 +108,9 @@ export default async ({ files, options, version: packageJson.version, - globals: {}, + globals: { + LOGLEVEL: JSON.stringify(logLevel), + }, headHtmlSnippet: getPreviewHeadHtml(configDir, process.env), dlls, bodyHtmlSnippet: getPreviewBodyHtml(configDir, process.env), From 24c44fc7d06e0523c9d20c68c64f0493a23d6968 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 10 Apr 2020 11:18:42 +0200 Subject: [PATCH 02/14] FIX lockfile --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index f4c43e741932..757b25b30e36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19631,7 +19631,7 @@ loglevel-plugin-prefix@^0.8.4: resolved "https://registry.yarnpkg.com/loglevel-plugin-prefix/-/loglevel-plugin-prefix-0.8.4.tgz#2fe0e05f1a820317d98d8c123e634c1bd84ff644" integrity sha512-WpG9CcFAOjz/FtNht+QJeGpvVl/cdR6P0z6OcXSkr8wFJOsV2GRj2j10JLfjuA4aYkcKCNIEqRGCyTife9R8/g== -loglevel@^1.4.1, loglevel@^1.6.4, loglevel@^1.6.6: +loglevel@^1.4.1, loglevel@^1.6.4, loglevel@^1.6.6, loglevel@^1.6.7: version "1.6.7" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.7.tgz#b3e034233188c68b889f5b862415306f565e2c56" integrity sha512-cY2eLFrQSAfVPhCgH1s7JI73tMbg9YC3v3+ZHVW67sBS7UxWzNEk/ZBbSfLykBWHp33dqqtOv82gjhKEi81T/A== From db162891c2e5532e0ca8a51702d323e841760ac0 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 10 Apr 2020 11:48:29 +0200 Subject: [PATCH 03/14] FIX tests --- addons/links/src/preview.test.js | 2 ++ addons/links/src/react/components/link.test.js | 1 + app/react/src/client/preview/index.test.ts | 2 +- lib/client-logger/src/index.test.ts | 3 +++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/links/src/preview.test.js b/addons/links/src/preview.test.js index 04bdeb2730f1..48d4b3d77034 100644 --- a/addons/links/src/preview.test.js +++ b/addons/links/src/preview.test.js @@ -17,6 +17,8 @@ jest.mock('global', () => ({ kind: 'kind', })), }, + window: global, + __STORYBOOK_LOGGER: 'warn', __STORYBOOK_CLIENT_API__: { raw: jest.fn(() => [ { diff --git a/addons/links/src/react/components/link.test.js b/addons/links/src/react/components/link.test.js index b38b6bf2bc9d..fd174ebe9d11 100644 --- a/addons/links/src/react/components/link.test.js +++ b/addons/links/src/react/components/link.test.js @@ -14,6 +14,7 @@ jest.mock('global', () => ({ search: 'search', }, }, + window: global, __STORYBOOK_STORY_STORE__: { getSelection: jest.fn(() => ({ id: 1 })), fromId: jest.fn(() => ({})), diff --git a/app/react/src/client/preview/index.test.ts b/app/react/src/client/preview/index.test.ts index bd25fc3ca828..6bd053669e7e 100644 --- a/app/react/src/client/preview/index.test.ts +++ b/app/react/src/client/preview/index.test.ts @@ -18,7 +18,7 @@ describe('preview', () => { () => ({ document: undefined, - window: undefined, + window: {}, } as any) ); const api = require('.'); diff --git a/lib/client-logger/src/index.test.ts b/lib/client-logger/src/index.test.ts index 0d2bc5782bcf..3272d11bf949 100644 --- a/lib/client-logger/src/index.test.ts +++ b/lib/client-logger/src/index.test.ts @@ -1,8 +1,11 @@ import { logger } from '.'; +jest.mock('loglevel', () => global.console); + describe('client-logger', () => { const initialConsole = { ...global.console }; beforeEach(() => { + global.console.trace = jest.fn(); global.console.debug = jest.fn(); global.console.log = jest.fn(); global.console.info = jest.fn(); From acc2de5551e6dc17bc61ddcec350192b0abd2585 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 13 Apr 2020 22:12:47 +0200 Subject: [PATCH 04/14] FIX --- addons/links/src/preview.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/links/src/preview.test.js b/addons/links/src/preview.test.js index 48d4b3d77034..88008541f0d2 100644 --- a/addons/links/src/preview.test.js +++ b/addons/links/src/preview.test.js @@ -18,7 +18,7 @@ jest.mock('global', () => ({ })), }, window: global, - __STORYBOOK_LOGGER: 'warn', + __STORYBOOK_LOGGER: console, __STORYBOOK_CLIENT_API__: { raw: jest.fn(() => [ { From 8cc33adef64f7162e13fc101a6d800e4d8ad6177 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 13 Apr 2020 22:14:56 +0200 Subject: [PATCH 05/14] Set correct initial value of logLevel --- lib/core/src/server/manager/manager-webpack.config.js | 2 +- lib/core/src/server/preview/iframe-webpack.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/src/server/manager/manager-webpack.config.js b/lib/core/src/server/manager/manager-webpack.config.js index 29d4ff3c36d8..ed6fc3a4e992 100644 --- a/lib/core/src/server/manager/manager-webpack.config.js +++ b/lib/core/src/server/manager/manager-webpack.config.js @@ -35,7 +35,7 @@ export default async ({ presets, }) => { const { raw, stringified } = loadEnv(); - const logLevel = await presets.apply('logLevel', []); + const logLevel = await presets.apply('logLevel', 'info'); const isProd = configType === 'PRODUCTION'; const refsTemplate = fse.readFileSync(path.join(__dirname, 'virtualModuleRef.template.js'), { encoding: 'utf8', diff --git a/lib/core/src/server/preview/iframe-webpack.config.js b/lib/core/src/server/preview/iframe-webpack.config.js index eb49ebe3db33..b1a59db9bb84 100644 --- a/lib/core/src/server/preview/iframe-webpack.config.js +++ b/lib/core/src/server/preview/iframe-webpack.config.js @@ -39,7 +39,7 @@ export default async ({ presets, }) => { const dlls = await presets.apply('webpackDlls', []); - const logLevel = await presets.apply('logLevel', []); + const logLevel = await presets.apply('logLevel', 'info'); const { raw, stringified } = loadEnv({ production: true }); const babelLoader = createBabelLoader(babelOptions); const isProd = configType === 'PRODUCTION'; From 2a5106c62038d9b13413cab7b3fb057e48bd2932 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 14 Apr 2020 00:02:15 +0200 Subject: [PATCH 06/14] ADD puppeteer as optionalDependency --- package.json | 3 ++- yarn.lock | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c29369fd1a25..614c34b6b2e6 100644 --- a/package.json +++ b/package.json @@ -235,7 +235,8 @@ }, "optionalDependencies": { "@cypress/webpack-preprocessor": "^4.1.0", - "cypress": "^4.0.2" + "cypress": "^4.0.2", + "puppeteer": "^2.1.1" }, "engines": { "node": ">=8.10.0", diff --git a/yarn.lock b/yarn.lock index ebe57ab1d521..8944bce24d73 100644 --- a/yarn.lock +++ b/yarn.lock @@ -24204,6 +24204,22 @@ puppeteer-core@2.1.1: rimraf "^2.6.1" ws "^6.1.0" +puppeteer@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-2.1.1.tgz#ccde47c2a688f131883b50f2d697bd25189da27e" + integrity sha512-LWzaDVQkk1EPiuYeTOj+CZRIjda4k2s5w4MK4xoH2+kgWV/SDlkYHmxatDdtYrciHUKSXTsGgPgPP8ILVdBsxg== + dependencies: + "@types/mime-types" "^2.1.0" + debug "^4.1.0" + extract-zip "^1.6.6" + https-proxy-agent "^4.0.0" + mime "^2.0.3" + mime-types "^2.1.25" + progress "^2.0.1" + proxy-from-env "^1.0.0" + rimraf "^2.6.1" + ws "^6.1.0" + purgecss@^1.4.0: version "1.4.2" resolved "https://registry.yarnpkg.com/purgecss/-/purgecss-1.4.2.tgz#67ab50cb4f5c163fcefde56002467c974e577f41" From 13a2e29c4bc2456e325ba01d5425080630e6db0e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 14 Apr 2020 01:05:36 +0200 Subject: [PATCH 07/14] FIX --- lib/cli/src/extract.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/cli/src/extract.js b/lib/cli/src/extract.js index 053b00338bec..3dc7d36f7561 100644 --- a/lib/cli/src/extract.js +++ b/lib/cli/src/extract.js @@ -79,13 +79,18 @@ const usePuppeteerBrowser = async () => { try { return await puppeteerCore.launch({ args }); } catch (e) { - // it's not installed - logger.info('installing puppeteer...'); return new Promise((resolve, reject) => { + // it's not installed + const l = () => logger.info('installing puppeteer...'); + const timer = setInterval(l, 20000); + l(); // eslint-disable-next-line global-require require('child_process').exec( `node ${require.resolve(path.join('puppeteer-core', 'install.js'))}`, - (error) => (error ? reject(error) : resolve(puppeteerCore.launch({ args }))) + (error) => { + clearInterval(timer); + return error ? reject(error) : resolve(puppeteerCore.launch({ args })); + } ); }); } From da6b2307e9142dd7a8243417573dbf374ad4011f Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 14 Apr 2020 01:37:57 +0200 Subject: [PATCH 08/14] FIX --- lib/cli/src/extract.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/cli/src/extract.js b/lib/cli/src/extract.js index 3dc7d36f7561..273e921c74ef 100644 --- a/lib/cli/src/extract.js +++ b/lib/cli/src/extract.js @@ -12,7 +12,8 @@ const read = async (url) => { await page.goto(url); await page.waitForFunction( - 'window.__STORYBOOK_STORY_STORE__ && window.__STORYBOOK_STORY_STORE__.extract && window.__STORYBOOK_STORY_STORE__.extract()' + 'window.__STORYBOOK_STORY_STORE__ && window.__STORYBOOK_STORY_STORE__.extract && window.__STORYBOOK_STORY_STORE__.extract()', + { timeout: 120000, polling: 'mutation' } ); const data = JSON.parse( await page.evaluate(async () => { @@ -81,14 +82,12 @@ const usePuppeteerBrowser = async () => { } catch (e) { return new Promise((resolve, reject) => { // it's not installed - const l = () => logger.info('installing puppeteer...'); - const timer = setInterval(l, 20000); - l(); + logger.info('installing puppeteer...'); + // eslint-disable-next-line global-require require('child_process').exec( `node ${require.resolve(path.join('puppeteer-core', 'install.js'))}`, (error) => { - clearInterval(timer); return error ? reject(error) : resolve(puppeteerCore.launch({ args })); } ); From d550600b0142f1db593645eaef16926d0358e064 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 14 May 2020 11:04:53 +0200 Subject: [PATCH 09/14] ADD a loglevel option for dev mode in CLI it's not used anywhere I think, but we're getting quite a few 'invalid cli option' errors, and this should get rid of them. --- lib/core/src/server/cli/dev.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/core/src/server/cli/dev.js b/lib/core/src/server/cli/dev.js index ab37a045b608..a4e14b5d5cfd 100644 --- a/lib/core/src/server/cli/dev.js +++ b/lib/core/src/server/cli/dev.js @@ -25,6 +25,7 @@ async function getCLI(packageJson) { .option('--ssl-key ', 'Provide an SSL key. (Required with --https)') .option('--smoke-test', 'Exit after successful start') .option('--ci', "CI mode (skip interactive prompts, don't open browser)") + .option('--loglevel [level]', 'Control level of logging during build') .option('--quiet', 'Suppress verbose build output') .option('--no-version-updates', 'Suppress update check', true) .option('--no-dll', 'Do not use dll reference') From 05e2cf0ba85bd25a7343736bd6872fdf951fd8d7 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 26 May 2020 13:52:01 +0200 Subject: [PATCH 10/14] FIX loglevel being a string within a string --- lib/core/src/server/manager/manager-webpack.config.js | 2 +- lib/core/src/server/preview/iframe-webpack.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/src/server/manager/manager-webpack.config.js b/lib/core/src/server/manager/manager-webpack.config.js index 9eb0831ad540..49fe2f0f8a5a 100644 --- a/lib/core/src/server/manager/manager-webpack.config.js +++ b/lib/core/src/server/manager/manager-webpack.config.js @@ -83,7 +83,7 @@ export default async ({ version, dlls: dll ? ['./sb_dll/storybook_ui_dll.js'] : [], globals: { - LOGLEVEL: JSON.stringify(logLevel), + LOGLEVEL: logLevel, VERSIONCHECK: JSON.stringify(versionCheck), DOCS_MODE: docsMode, // global docs mode PREVIEW_URL: previewUrl, // global preview URL diff --git a/lib/core/src/server/preview/iframe-webpack.config.js b/lib/core/src/server/preview/iframe-webpack.config.js index 24b4eba53932..55cc95d8accd 100644 --- a/lib/core/src/server/preview/iframe-webpack.config.js +++ b/lib/core/src/server/preview/iframe-webpack.config.js @@ -114,7 +114,7 @@ export default async ({ options, version: packageJson.version, globals: { - LOGLEVEL: JSON.stringify(logLevel), + LOGLEVEL: logLevel, }, headHtmlSnippet: getPreviewHeadHtml(configDir, process.env), dlls, From 8b4a7e237b728ecff8b37775125af8498724d169 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 26 May 2020 16:00:01 +0200 Subject: [PATCH 11/14] FIX lockfile && safety check for window --- lib/client-logger/src/index.ts | 6 ++++-- yarn.lock | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/client-logger/src/index.ts b/lib/client-logger/src/index.ts index 6b1801055047..6dedb9df4991 100644 --- a/lib/client-logger/src/index.ts +++ b/lib/client-logger/src/index.ts @@ -14,8 +14,10 @@ if (LOGLEVEL) { console.setLevel(LOGLEVEL); } -// eslint-disable-next-line no-underscore-dangle -window.__STORYBOOK_LOGGER = console; +if (window) { + // eslint-disable-next-line no-underscore-dangle + window.__STORYBOOK_LOGGER = console; +} export const pretty = (type: 'trace' | 'debug' | 'info' | 'warn' | 'error') => ( ...args: string[] diff --git a/yarn.lock b/yarn.lock index a608e008471a..e96b3b960a64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21656,11 +21656,7 @@ loglevel-plugin-prefix@^0.8.4: resolved "https://registry.yarnpkg.com/loglevel-plugin-prefix/-/loglevel-plugin-prefix-0.8.4.tgz#2fe0e05f1a820317d98d8c123e634c1bd84ff644" integrity sha512-WpG9CcFAOjz/FtNht+QJeGpvVl/cdR6P0z6OcXSkr8wFJOsV2GRj2j10JLfjuA4aYkcKCNIEqRGCyTife9R8/g== -<<<<<<< HEAD -loglevel@^1.4.1, loglevel@^1.6.4, loglevel@^1.6.6, loglevel@^1.6.7: -======= -loglevel@^1.4.1, loglevel@^1.6.4, loglevel@^1.6.6, loglevel@^1.6.8: ->>>>>>> next +loglevel@^1.4.1, loglevel@^1.6.4, loglevel@^1.6.6, loglevel@^1.6.7, loglevel@^1.6.8: version "1.6.8" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.8.tgz#8a25fb75d092230ecd4457270d80b54e28011171" integrity sha512-bsU7+gc9AJ2SqpzxwU3+1fedl8zAntbtC5XYlt3s2j1hJcn2PsXSmgN8TaLG/J1/2mod4+cE/3vNL70/c1RNCA== From b26e8c1790b15574dd40438b42944083f3f2daa0 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 29 May 2020 12:13:32 +0200 Subject: [PATCH 12/14] ADD docs --- docs/src/pages/configurations/overview/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/pages/configurations/overview/index.md b/docs/src/pages/configurations/overview/index.md index 0c8de1bc57d6..5c9de8814fb8 100644 --- a/docs/src/pages/configurations/overview/index.md +++ b/docs/src/pages/configurations/overview/index.md @@ -26,6 +26,8 @@ module.exports = { `stories` is a list of [glob](https://www.npmjs.com/package/glob) patterns that tells where your stories are located, relative to the configuration file. +`logLevel` is a setting that tells storybook to only log to a specific level. Options are: `trace`, `debug`, `info`, `warn`, `error` and `silent`. + The `addons` field can refer to traditional [addons](../../addons/introduction), but it can also include [presets](/docs/presets/introduction/), which are able to extend the config further. ### `main.js` is a Preset From c604b2626b70bbd0ddbd38fe61242a9ff79690c1 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 29 May 2020 12:31:07 +0200 Subject: [PATCH 13/14] set loglevel for node based on cli param in dev-mode --- lib/core/src/server/cli/dev.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/core/src/server/cli/dev.js b/lib/core/src/server/cli/dev.js index a4e14b5d5cfd..050b4f9de5b5 100644 --- a/lib/core/src/server/cli/dev.js +++ b/lib/core/src/server/cli/dev.js @@ -37,6 +37,8 @@ async function getCLI(packageJson) { .option('--docs', 'Build a documentation-only site using addon-docs') .parse(process.argv); + logger.setLevel(program.loglevel); + // Workaround the `-h` shorthand conflict. // Output the help if `-h` is called without any value. // See storybookjs/storybook#5360 From 7078a12921faf235764b74f40504d5a2b79497b1 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 29 May 2020 12:31:31 +0200 Subject: [PATCH 14/14] Use cli param to set default loglevel in preset --- lib/core/src/server/common/common-preset.js | 2 +- lib/core/src/server/manager/manager-webpack.config.js | 2 +- lib/core/src/server/preview/iframe-webpack.config.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/src/server/common/common-preset.js b/lib/core/src/server/common/common-preset.js index 10b15ffe7797..8ef5e36fa30f 100644 --- a/lib/core/src/server/common/common-preset.js +++ b/lib/core/src/server/common/common-preset.js @@ -10,4 +10,4 @@ export const babel = async (_, options) => { ); }; -export const logLevel = () => 'info'; +export const logLevel = (previous, options) => previous || options.loglevel || 'info'; diff --git a/lib/core/src/server/manager/manager-webpack.config.js b/lib/core/src/server/manager/manager-webpack.config.js index 49fe2f0f8a5a..488f33b31db0 100644 --- a/lib/core/src/server/manager/manager-webpack.config.js +++ b/lib/core/src/server/manager/manager-webpack.config.js @@ -38,7 +38,7 @@ export default async ({ presets, }) => { const { raw, stringified } = loadEnv(); - const logLevel = await presets.apply('logLevel', 'info'); + const logLevel = await presets.apply('logLevel', undefined); const isProd = configType === 'PRODUCTION'; const refsTemplate = fse.readFileSync(path.join(__dirname, 'virtualModuleRef.template.js'), { encoding: 'utf8', diff --git a/lib/core/src/server/preview/iframe-webpack.config.js b/lib/core/src/server/preview/iframe-webpack.config.js index 55cc95d8accd..3453f3d1ffa6 100644 --- a/lib/core/src/server/preview/iframe-webpack.config.js +++ b/lib/core/src/server/preview/iframe-webpack.config.js @@ -42,7 +42,7 @@ export default async ({ typescriptOptions, }) => { const dlls = await presets.apply('webpackDlls', []); - const logLevel = await presets.apply('logLevel', 'info'); + const logLevel = await presets.apply('logLevel', undefined); const { raw, stringified } = loadEnv({ production: true }); const babelLoader = createBabelLoader(babelOptions, framework); const isProd = configType === 'PRODUCTION';