mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-20 20:07:03 -04:00
Patcher: More useful errors with code diffs (#177)
* Patcher: More useful errors with code diffs * Nicer log formatting * PluginCards: ellipsises
This commit is contained in:
parent
739b1e47d4
commit
3af9a14a0e
8 changed files with 102 additions and 20 deletions
|
@ -17,11 +17,23 @@
|
|||
*/
|
||||
|
||||
export default class Logger {
|
||||
/**
|
||||
* Returns the console format args for a title with the specified background colour and black text
|
||||
* @param color Background colour
|
||||
* @param title Text
|
||||
* @returns Array. Destructure this into {@link Logger}.errorCustomFmt or console.log
|
||||
*
|
||||
* @example logger.errorCustomFmt(...Logger.makeTitleElements("white", "Hello"), "World");
|
||||
*/
|
||||
static makeTitle(color: string, title: string): [string, ...string[]] {
|
||||
return ["%c %c %s ", "", `background: ${color}; color: black; font-weight: bold; border-radius: 5px;`, title];
|
||||
}
|
||||
|
||||
constructor(public name: string, public color: string) { }
|
||||
|
||||
private _log(level: "log" | "error" | "warn" | "info" | "debug", levelColor: string, args: any[]) {
|
||||
private _log(level: "log" | "error" | "warn" | "info" | "debug", levelColor: string, args: any[], customFmt = "") {
|
||||
console[level](
|
||||
`%c Vencord %c %c ${this.name} `,
|
||||
`%c Vencord %c %c ${this.name} ${customFmt}`,
|
||||
`background: ${levelColor}; color: black; font-weight: bold; border-radius: 5px;`,
|
||||
"",
|
||||
`background: ${this.color}; color: black; font-weight: bold; border-radius: 5px;`
|
||||
|
@ -41,6 +53,10 @@ export default class Logger {
|
|||
this._log("error", "#e78284", args);
|
||||
}
|
||||
|
||||
public errorCustomFmt(fmt: string, ...args: any[]) {
|
||||
this._log("error", "#e78284", args, fmt);
|
||||
}
|
||||
|
||||
public warn(...args: any[]) {
|
||||
this._log("warn", "#e5c890", args);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue