UNPKG

@kwiz/common

Version:

KWIZ common utilities and helpers for M365 platform

70 lines 2.69 kB
import { CommonConfig } from './common-config'; import { ConsoleLogger } from './utils/consolelogger'; /** to be used by 3rd party apps to get the latet project config. Main project entry point will have to call config. */ export class CommonLogger { constructor(name) { this.instance = null; this.name = name; } get i() { if (this.instance === null || this.instance.context.prefix !== CommonConfig.i.ProjectName) { if (!CommonConfig.i._configured) console.warn('@kwiz/common not configured yet! Call config before this code runs.'); this.instance = ConsoleLogger.get(this.name, 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); } } //# sourceMappingURL=common-logger.js.map