Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
feat: logger supports console.table, with console.log fallback (#738)
Browse files Browse the repository at this point in the history
* feat: logger.table

* applying Jesse's feedback

* missed a method
  • Loading branch information
rusackas authored Aug 17, 2020
1 parent d323ce8 commit 4f0e4d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/superset-ui-core/src/utils/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
const logger = window.console || {
debug() {},
log() {},
info() {},
warn() {},
error() {},
trace() {},

const console = window.console || {};
const log = console.log || (() => {});

const logger = {
log,
debug: console.debug || 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;
4 changes: 4 additions & 0 deletions packages/superset-ui-core/test/utils/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ describe('logging', () => {
logging.warn('warn');
logging.error('error');
logging.trace();
logging.table([
[1, 2],
[3, 4],
]);
}).not.toThrow();
});
});

1 comment on commit 4f0e4d1

@vercel
Copy link

@vercel vercel bot commented on 4f0e4d1 Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.