patternfly-elements
patternfly-elements copied to clipboard
[feat] Add error logging to pfelement
Something like this but for errors 🙃
/**
* A console warning wrapper which formats your output with useful debugging information.
*
* @example PFElement.warn("Hello");
*/
static warn(...msgs) {
console.warn(...msgs);
}
/**
* Local warning wrapper that outputs the tag name as a prefix automatically.
* For use inside a component's function.
* @example this.warn("Hello");
*/
warn(...msgs) {
PFElement.warn(`[${this.tag}${this.id ? `#${this.id}` : ``}]`, ...msgs);
}
we've migrated from PFElement to LitElement, but maintained all the logging logic in https://github.com/patternfly/patternfly-elements/blob/main/core/pfe-core/controllers/logger.ts
We have an error method there, but it actually throws an error. I did not find any references in the code to that method. I'd be very happy to remove the throw new Error statement and just log whichever values the method receives at error level.