UNPKG

@kwiz/common

Version:

KWIZ common utilities and helpers for M365 platform

74 lines 2.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommonLogger = void 0; const common_config_1 = require("./common-config"); const consolelogger_1 = require("./utils/consolelogger"); /** to be used by 3rd party apps to get the latet project config. Main project entry point will have to call config. */ class CommonLogger { constructor(name) { this.instance = null; this.name = name; } get i() { if (this.instance === null || this.instance.context.prefix !== common_config_1.CommonConfig.i.ProjectName) { if (!common_config_1.CommonConfig.i._configured) console.warn('@kwiz/common not configured yet! Call config before this code runs.'); this.instance = consolelogger_1.ConsoleLogger.get(this.name, common_config_1.CommonConfig.i.ProjectName); } return this.instance; } ; debug(message) { return this.i.debug(message); } info(message) { return this.i.info(message); } log(message) { return this.i.log(message); } /** output a message when debug is off */ warn(message) { return this.i.warn(message); } /** output a message when debug is off */ error(message) { return this.i.error(message); } /** output a message when debug is off */ trace(message) { return this.i.trace(message); } /**start timer on a label, call timeEnd with the same label to print out the time that passed */ time(label) { return this.i.time(label); } /**start timer on a label, call timeEnd with the same label to print out the time that passed */ timeEnd(label) { return this.i.timeEnd(label); } /**prints an array or dictionary to the console inside a group */ table(data, groupLabel, groupCollapsed) { return this.i.table(data, groupLabel, groupCollapsed); } /**prints a JSON object to the console inside a group */ json(data, groupLabel, groupCollapsed) { return this.i.json(data, groupLabel, groupCollapsed); } /**prints an XML object to the console inside a group. If data is string that looks like an XML - will try to parse it. */ xml(data, groupLabel, groupCollapsed) { return this.i.xml(data, groupLabel, groupCollapsed); } /** render messages inside a group, and closes the group when done. if a label is not provided - a group will not be rendered */ group(renderContent, label, collapsed) { return this.i.group(renderContent, label, collapsed); } groupSync(label, renderContent, options) { return this.i.groupSync(label, renderContent); } async groupAsync(label, renderContent, options) { return this.i.groupAsync(label, renderContent); } } exports.CommonLogger = CommonLogger; //# sourceMappingURL=common-logger.js.map