From 9a011e47c3edb34d0aafed4856414b571b49645f Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Fri, 14 Aug 2020 17:12:41 -0700 Subject: [PATCH 1/3] feat: logger.table --- packages/superset-ui-core/src/utils/logging.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/superset-ui-core/src/utils/logging.ts b/packages/superset-ui-core/src/utils/logging.ts index c4f2a23345..bd0ebfd8e3 100644 --- a/packages/superset-ui-core/src/utils/logging.ts +++ b/packages/superset-ui-core/src/utils/logging.ts @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + const logger = window.console || { debug() {}, log() {}, @@ -25,6 +26,10 @@ const logger = window.console || { trace() {}, }; +const table = window.console?.table || logger.log; + +logger.table = table; + /** * Superset frontend logger, currently just an alias to console. */ From bc360496857bb0a239ead849aca17ba2c3c2a2ac Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Sun, 16 Aug 2020 20:49:28 -0700 Subject: [PATCH 2/3] applying Jesse's feedback --- .../superset-ui-core/src/utils/logging.ts | 23 ++++++++++--------- .../test/utils/logging.test.ts | 4 ++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/superset-ui-core/src/utils/logging.ts b/packages/superset-ui-core/src/utils/logging.ts index bd0ebfd8e3..b9223aa90c 100644 --- a/packages/superset-ui-core/src/utils/logging.ts +++ b/packages/superset-ui-core/src/utils/logging.ts @@ -17,20 +17,21 @@ * under the License. */ -const logger = window.console || { - debug() {}, - log() {}, - info() {}, - warn() {}, - error() {}, - trace() {}, -}; - -const table = window.console?.table || logger.log; +const console = window.console || {}; +const log = console.log || (() => {}); -logger.table = table; +const logger = { + log, + info: console.info || log, + warn: console.warn || log, + error: console.error || log, + trace: console.trace || log, + table: console.table || log, +}; /** * Superset frontend logger, currently just an alias to console. + * This may be extended to support numerous console operations safely + * i.e.: https://developer.mozilla.org/en-US/docs/Web/API/Console */ export default logger; diff --git a/packages/superset-ui-core/test/utils/logging.test.ts b/packages/superset-ui-core/test/utils/logging.test.ts index 2d4ff781f9..3707977d07 100644 --- a/packages/superset-ui-core/test/utils/logging.test.ts +++ b/packages/superset-ui-core/test/utils/logging.test.ts @@ -55,6 +55,10 @@ describe('logging', () => { logging.warn('warn'); logging.error('error'); logging.trace(); + logging.table([ + [1, 2], + [3, 4], + ]); }).not.toThrow(); }); }); From 8c2fd21c3bd29b4b49c108c43643f81d4fc610e5 Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Sun, 16 Aug 2020 21:13:31 -0700 Subject: [PATCH 3/3] missed a method --- packages/superset-ui-core/src/utils/logging.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/superset-ui-core/src/utils/logging.ts b/packages/superset-ui-core/src/utils/logging.ts index b9223aa90c..929c4d0fb9 100644 --- a/packages/superset-ui-core/src/utils/logging.ts +++ b/packages/superset-ui-core/src/utils/logging.ts @@ -22,6 +22,7 @@ const log = console.log || (() => {}); const logger = { log, + debug: console.debug || log, info: console.info || log, warn: console.warn || log, error: console.error || log,