Skip to content

Commit

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

* feat: logger.table

* applying Jesse's feedback

* missed a method
  • Loading branch information
rusackas authored and zhaoyongjie committed Nov 17, 2021
1 parent 9b9c39c commit e4b16e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
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;
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();
});
});

0 comments on commit e4b16e0

Please sign in to comment.