UNPKG

876 BJavaScriptView Raw
1"use strict";
2/* istanbul ignore file */
3Object.defineProperty(exports, "__esModule", { value: true });
4const LOG_METHODS = ['error', 'warn', 'info', 'debug', 'trace', 'silent'];
5function getLogger(component) {
6 return LOG_METHODS.reduce((acc, cur) => {
7 const prop = cur;
8 // check if the method is available on console (web doesn't have
9 // 'silent', for example) before adding to acc
10 // eslint-disable-next-line no-console
11 if (console[prop]) {
12 // eslint-disable-next-line no-console
13 acc[prop] = console[prop].bind(console, `${component}:`);
14 }
15 return acc;
16 }, {});
17}
18exports.default = getLogger;
19// logging interface expects a 'setLevel' method
20getLogger.setLevel = () => { };
21getLogger.setLogLevelsConfig = () => { };
22getLogger.waitForBuffer = () => { };
23getLogger.clearLogger = () => { };