From 829cfdefacce412ca80ea744c45efd38f1f2c790 Mon Sep 17 00:00:00 2001 From: Vance Hu Date: Thu, 4 Apr 2019 12:36:47 -0400 Subject: [PATCH 1/3] feat: morgan - skip successful requests if 'verbose' is set to false --- packages/cli/src/commands/server/runServer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/server/runServer.js b/packages/cli/src/commands/server/runServer.js index 8b20376c1..0cfcf9d95 100644 --- a/packages/cli/src/commands/server/runServer.js +++ b/packages/cli/src/commands/server/runServer.js @@ -62,7 +62,14 @@ async function runServer(argv: Array, ctx: ContextT, args: Args) { watchFolders: metroConfig.watchFolders, }); - middlewareManager.getConnectInstance().use(morgan('combined')); + middlewareManager.getConnectInstance().use( + morgan( + 'combined', + !args.verbose && { + skip: (req, res) => res.statusCode < 400, + }, + ), + ); metroConfig.watchFolders.forEach( middlewareManager.serveStatic.bind(middlewareManager), From 0415a790bb0c6cdcbcbe7e17f9dca0a30d6b57c1 Mon Sep 17 00:00:00 2001 From: Vance Hu Date: Tue, 9 Apr 2019 14:03:28 -0400 Subject: [PATCH 2/3] fix: use isVerbose instead of args.verbose in morgan --- packages/cli/src/commands/server/runServer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/server/runServer.js b/packages/cli/src/commands/server/runServer.js index c6f9471c8..ecc8ca3cc 100644 --- a/packages/cli/src/commands/server/runServer.js +++ b/packages/cli/src/commands/server/runServer.js @@ -19,6 +19,7 @@ import webSocketProxy from './webSocketProxy'; import MiddlewareManager from './middleware/MiddlewareManager'; import loadMetroConfig from '../../tools/loadMetroConfig'; +import logger from '../../../../tools/src/logger'; export type Args = {| assetExts?: string[], @@ -65,7 +66,7 @@ async function runServer(argv: Array, ctx: ConfigT, args: Args) { middlewareManager.getConnectInstance().use( morgan( 'combined', - !args.verbose && { + !logger.isVerbose() && { skip: (req, res) => res.statusCode < 400, }, ), From 8a44d16ff1420958e07064531abcd96b0e8109ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 10 Apr 2019 16:32:07 +0200 Subject: [PATCH 3/3] Update runServer.js --- packages/cli/src/commands/server/runServer.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/cli/src/commands/server/runServer.js b/packages/cli/src/commands/server/runServer.js index ecc8ca3cc..181d8fd34 100644 --- a/packages/cli/src/commands/server/runServer.js +++ b/packages/cli/src/commands/server/runServer.js @@ -8,18 +8,15 @@ */ import Metro from 'metro'; - import {Terminal} from 'metro-core'; - import morgan from 'morgan'; import path from 'path'; +import {logger} from '@react-native-community/cli-tools'; import type {ConfigT} from '../../tools/config/types.flow'; import messageSocket from './messageSocket'; import webSocketProxy from './webSocketProxy'; import MiddlewareManager from './middleware/MiddlewareManager'; - import loadMetroConfig from '../../tools/loadMetroConfig'; -import logger from '../../../../tools/src/logger'; export type Args = {| assetExts?: string[],