aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorVen <vendicated@riseup.net>2022-10-30 02:58:11 +0100
committerGitHub <noreply@github.com>2022-10-30 02:58:11 +0100
commit3af9a14a0e78be88c5a048b79187c32796c06a7c (patch)
treea7fa6601555fd03b15da5685df40c3d33cbb89bd /src/utils
parent739b1e47d40d645076bb74d82355f5e45edcd84e (diff)
downloadVencord-3af9a14a0e78be88c5a048b79187c32796c06a7c.tar.gz
Vencord-3af9a14a0e78be88c5a048b79187c32796c06a7c.tar.bz2
Vencord-3af9a14a0e78be88c5a048b79187c32796c06a7c.zip
Patcher: More useful errors with code diffs (#177)
* Patcher: More useful errors with code diffs * Nicer log formatting * PluginCards: ellipsises
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/logger.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/utils/logger.ts b/src/utils/logger.ts
index 309f4db..24cd2c8 100644
--- a/src/utils/logger.ts
+++ b/src/utils/logger.ts
@@ -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);
}