diff --git a/src/supabase/helpers/tables/logs.ts b/src/supabase/helpers/tables/logs.ts index 2a146e4..c36ccd8 100644 --- a/src/supabase/helpers/tables/logs.ts +++ b/src/supabase/helpers/tables/logs.ts @@ -52,55 +52,51 @@ export class Logs { return metadata; } - public ok(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null { + public ok(log: string, metadata?: Metadata): LogReturn | null { metadata = this._addDiagnosticInformation(metadata); return this._log({ level: LOG_LEVEL.INFO, consoleLog: Logs.console.ok, logMessage: log, metadata, - postComment, type: "ok", }); } - public info(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null { + public info(log: string, metadata?: Metadata): LogReturn | null { metadata = this._addDiagnosticInformation(metadata); return this._log({ level: LOG_LEVEL.INFO, consoleLog: Logs.console.info, logMessage: log, metadata, - postComment, type: "info", }); } - public error(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null { + public error(log: string, metadata?: Metadata): LogReturn | null { metadata = this._addDiagnosticInformation(metadata); return this._log({ level: LOG_LEVEL.ERROR, consoleLog: Logs.console.error, logMessage: log, metadata, - postComment, type: "error", }); } - public debug(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null { + public debug(log: string, metadata?: Metadata): LogReturn | null { metadata = this._addDiagnosticInformation(metadata); return this._log({ level: LOG_LEVEL.DEBUG, consoleLog: Logs.console.debug, logMessage: log, metadata, - postComment, type: "debug", }); } - public fatal(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null { + public fatal(log: string, metadata?: Metadata): LogReturn | null { if (!metadata) { metadata = Logs.convertErrorsIntoObjects(new Error(log)) as Metadata; const stack = metadata.stack as string[]; @@ -121,19 +117,17 @@ export class Logs { consoleLog: Logs.console.fatal, logMessage: log, metadata, - postComment, type: "fatal", }); } - public verbose(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null { + public verbose(log: string, metadata?: Metadata): LogReturn | null { metadata = this._addDiagnosticInformation(metadata); return this._log({ level: LOG_LEVEL.VERBOSE, consoleLog: Logs.console.verbose, logMessage: log, metadata, - postComment, type: "verbose", }); } diff --git a/src/supabase/helpers/tables/pretty-logs.ts b/src/supabase/helpers/tables/pretty-logs.ts index 2af7988..736cf6a 100644 --- a/src/supabase/helpers/tables/pretty-logs.ts +++ b/src/supabase/helpers/tables/pretty-logs.ts @@ -1,4 +1,3 @@ -import util from "util"; import { Colors, Metadata, PrettyLogsWithOk } from "../../types/log-types"; import { COLORS, LOG_LEVEL } from "../../constants"; @@ -109,7 +108,7 @@ export class PrettyLogs { const symbol = defaultSymbols[type]; // Formatting the message - const messageFormatted = typeof message === "string" ? message : util.inspect(message, { showHidden: true, depth: null, breakLength: Infinity }); + const messageFormatted = typeof message === "string" ? message : JSON.stringify(message, null, 2); // const messageFormatted = // typeof message === "string" ? message : JSON.stringify(Logs.convertErrorsIntoObjects(message)); @@ -135,8 +134,11 @@ export class PrettyLogs { }; const _console = console[colorMap[type][0] as keyof typeof console] as (...args: string[]) => void; - if (typeof _console === "function") { + if (typeof _console === "function" && fullLogString.length > 12) { _console(this._colorizeText(fullLogString, colorMap[type][1])); + } else if (fullLogString.length <= 12) { + // removing empty logs which only contain the symbol + return; } else { throw new Error(fullLogString); } diff --git a/src/supabase/types/log-types.ts b/src/supabase/types/log-types.ts index 996b45b..60f14d2 100644 --- a/src/supabase/types/log-types.ts +++ b/src/supabase/types/log-types.ts @@ -13,7 +13,6 @@ export type LogParams = { consoleLog: LogFunction; logMessage: string; metadata?: Metadata; - postComment?: boolean; type: PrettyLogsWithOk; }; diff --git a/src/supabase/utils.ts b/src/supabase/utils.ts new file mode 100644 index 0000000..210fdf0 --- /dev/null +++ b/src/supabase/utils.ts @@ -0,0 +1,32 @@ +const ansiEscapeCodes = /\x1b\[\d+m|\s/g; + +function cleanLogs( + spy: jest.SpiedFunction<{ + (...data: string[]): void; + (message?: string, ...optionalParams: string[]): void; + }> +) { + const strs = spy.mock.calls.map((call) => call.map((str) => str?.toString()).join(" ")); + return strs.flat().map((str) => cleanLogString(str)); +} + +export function cleanLogString(logString: string) { + return logString.replaceAll(ansiEscapeCodes, "").replaceAll(/\n/g, "").replaceAll(/\r/g, "").replaceAll(/\t/g, "").trim(); +} + +export function cleanSpyLogs( + spy: jest.SpiedFunction<{ + (...data: string[]): void; + (message?: string, ...optionalParams: string[]): void; + }> +): string[] { + return cleanLogs(spy); +} + +export function tryError() { + try { + throw new Error("This is an error"); + } catch (e) { + return e as Error; + } +} diff --git a/static/fonts/ubiquity-nova-standard.eot b/static/fonts/ubiquity-nova-standard.eot deleted file mode 100644 index 1e46099..0000000 Binary files a/static/fonts/ubiquity-nova-standard.eot and /dev/null differ diff --git a/static/fonts/ubiquity-nova-standard.ttf b/static/fonts/ubiquity-nova-standard.ttf deleted file mode 100644 index d953486..0000000 Binary files a/static/fonts/ubiquity-nova-standard.ttf and /dev/null differ diff --git a/static/fonts/ubiquity-nova-standard.woff b/static/fonts/ubiquity-nova-standard.woff deleted file mode 100644 index 0c2691e..0000000 Binary files a/static/fonts/ubiquity-nova-standard.woff and /dev/null differ diff --git a/static/index.html b/static/index.html deleted file mode 100644 index dbae5f4..0000000 --- a/static/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - -
- - -