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

feat: logger supports console.table, with console.log fallback #738

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});