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

* feat: logger.table

* applying Jesse's feedback

* missed a method
This commit is contained in:
Evan Rusackas 2020-08-16 21:31:55 -07:00 committed by Yongjie Zhao
parent 2fd1070a2e
commit 86eedab4d0
2 changed files with 18 additions and 7 deletions

View File

@ -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;

View File

@ -55,6 +55,10 @@ describe('logging', () => {
logging.warn('warn');
logging.error('error');
logging.trace();
logging.table([
[1, 2],
[3, 4],
]);
}).not.toThrow();
});
});