From 3ac8774fdb9acd64b68f9ba1cfa7cda6701b8d1b Mon Sep 17 00:00:00 2001 From: Cody Chan Date: Fri, 25 Oct 2019 11:53:30 +0800 Subject: [PATCH 1/2] fix(util): fix wrong log display for scoped plugin --- packages/svrx-util/lib/logger.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/svrx-util/lib/logger.js b/packages/svrx-util/lib/logger.js index 208401a..3bfc13d 100644 --- a/packages/svrx-util/lib/logger.js +++ b/packages/svrx-util/lib/logger.js @@ -135,8 +135,7 @@ LEVELS.forEach((level) => { }); function getPluginLogger(name) { - const categoryName = `plugin-${name}`; - return new Logger(categoryName); + return new Logger(name); } const logger = new Logger(); From 084bd5852df4258660fa99aa32a2e2a4054b1e85 Mon Sep 17 00:00:00 2001 From: xuchaoying Date: Mon, 28 Oct 2019 16:26:20 +0800 Subject: [PATCH 2/2] test: add testcase to logger --- packages/svrx-util/__tests__/spec/logger.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/svrx-util/__tests__/spec/logger.test.js b/packages/svrx-util/__tests__/spec/logger.test.js index 387a606..6234e0c 100644 --- a/packages/svrx-util/__tests__/spec/logger.test.js +++ b/packages/svrx-util/__tests__/spec/logger.test.js @@ -89,4 +89,9 @@ describe('logger', () => { }); }); }); + + it('should change category throught #getPluginLogger()', () => { + const pluginLogger = logger.getPluginLogger('test-plugin'); + expect(pluginLogger.category).to.eql('test-plugin'); + }); });