diff --git a/dist/logs.d.ts b/dist/logs.d.ts index 87569ea..d8bc1c3 100644 --- a/dist/logs.d.ts +++ b/dist/logs.d.ts @@ -1,53 +1,21 @@ -import { SupabaseClient } from "@supabase/supabase-js"; -import { Context } from "probot"; -import { LogLevel, PrettyLogs } from "./pretty-logs.js"; +import { P as PrettyLogs, M as Metadata, L as LogReturn, a as LogLevel } from './pretty-logs-TeMdXxew.js'; -declare class LogReturn { - logMessage: LogMessage; - metadata?: any; - constructor(logMessage: LogMessage, metadata?: any); -} -type FunctionPropertyNames = { - [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never; -}[keyof T]; -type PublicMethods = Exclude, "constructor" | keyof object>; -type LogMessage = { - raw: string; - diff: string; - level: LogLevel; - type: PublicMethods; -}; declare class Logs { - private _supabase; - private _context; - private _maxLevel; - private _queue; - private _concurrency; - private _retryDelay; - private _throttleCount; - private _retryLimit; - static console: PrettyLogs; - private _log; - private _addDiagnosticInformation; - ok(log: string, metadata?: any, postComment?: boolean): LogReturn | null; - info(log: string, metadata?: any, postComment?: boolean): LogReturn | null; - error(log: string, metadata?: any, postComment?: boolean): LogReturn | null; - debug(log: string, metadata?: any, postComment?: boolean): LogReturn | null; - fatal(log: string, metadata?: any, postComment?: boolean): LogReturn | null; - verbose(log: string, metadata?: any, postComment?: boolean): LogReturn | null; - constructor(supabase: SupabaseClient, retryLimit: number, logLevel: LogLevel, context: Context | null); - private _sendLogsToSupabase; - private _processLogs; - private _retryLog; - private _processLogQueue; - private _throttle; - private _addToQueue; - private _save; - static _commentMetaData(metadata: any, level: LogLevel): string; - private _diffColorCommentMessage; - private _postComment; - private _getNumericLevel; - static convertErrorsIntoObjects(obj: any): any; + private _maxLevel; + static console: PrettyLogs; + private _log; + private _addDiagnosticInformation; + ok(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null; + info(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null; + error(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null; + debug(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null; + fatal(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null; + verbose(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null; + constructor(logLevel: LogLevel); + static _commentMetaData(metadata: Metadata, level: LogLevel): string; + private _diffColorCommentMessage; + private _getNumericLevel; + static convertErrorsIntoObjects(obj: unknown): Metadata | unknown; } -export { type LogMessage, LogReturn, Logs }; +export { Logs }; diff --git a/dist/logs.js b/dist/logs.js index a34c273..71d40da 100644 --- a/dist/logs.js +++ b/dist/logs.js @@ -1,12 +1,41 @@ -// src/commit-hash.ts -import { execSync } from "child_process"; -var COMMIT_HASH = null; -try { - COMMIT_HASH = execSync("git rev-parse --short HEAD").toString().trim(); -} catch (e) {} - // src/supabase/helpers/tables/pretty-logs.ts import util from "util"; + +// src/supabase/constants.ts +var COLORS = { + reset: "\x1B[0m", + bright: "\x1B[1m", + dim: "\x1B[2m", + underscore: "\x1B[4m", + blink: "\x1B[5m", + reverse: "\x1B[7m", + hidden: "\x1B[8m", + fgBlack: "\x1B[30m", + fgRed: "\x1B[31m", + fgGreen: "\x1B[32m", + fgYellow: "\x1B[33m", + fgBlue: "\x1B[34m", + fgMagenta: "\x1B[35m", + fgCyan: "\x1B[36m", + fgWhite: "\x1B[37m", + bgBlack: "\x1B[40m", + bgRed: "\x1B[41m", + bgGreen: "\x1B[42m", + bgYellow: "\x1B[43m", + bgBlue: "\x1B[44m", + bgMagenta: "\x1B[45m", + bgCyan: "\x1B[46m", + bgWhite: "\x1B[47m" +}; +var LOG_LEVEL = { + FATAL: "fatal", + ERROR: "error", + INFO: "info", + VERBOSE: "verbose", + DEBUG: "debug" +}; + +// src/supabase/helpers/tables/pretty-logs.ts var PrettyLogs = class { constructor() { this.ok = this.ok.bind(this); @@ -17,30 +46,31 @@ var PrettyLogs = class { this.verbose = this.verbose.bind(this); } fatal(message, metadata) { - this._logWithStack("fatal" /* FATAL */, message, metadata); + this._logWithStack(LOG_LEVEL.FATAL, message, metadata); } error(message, metadata) { - this._logWithStack("error" /* ERROR */, message, metadata); + this._logWithStack(LOG_LEVEL.ERROR, message, metadata); } ok(message, metadata) { this._logWithStack("ok", message, metadata); } info(message, metadata) { - this._logWithStack("info" /* INFO */, message, metadata); + this._logWithStack(LOG_LEVEL.INFO, message, metadata); } debug(message, metadata) { - this._logWithStack("debug" /* DEBUG */, message, metadata); + this._logWithStack(LOG_LEVEL.DEBUG, message, metadata); } verbose(message, metadata) { - this._logWithStack("verbose" /* VERBOSE */, message, metadata); + this._logWithStack(LOG_LEVEL.VERBOSE, message, metadata); } - _logWithStack(type, message, metadata) { + _logWithStack(type, message, metaData) { this._log(type, message); - if (typeof metadata === "string") { - this._log(type, metadata); + if (typeof metaData === "string") { + this._log(type, metaData); return; } - if (metadata) { + if (metaData) { + const metadata = metaData; let stack = metadata?.error?.stack || metadata?.stack; if (!stack) { const stackTrace = new Error().stack?.split("\n"); @@ -58,11 +88,11 @@ var PrettyLogs = class { } if (typeof stack == "string") { const prettyStack = this._formatStackTrace(stack, 1); - const colorizedStack = this._colorizeText(prettyStack, "\x1B[2m" /* dim */); + const colorizedStack = this._colorizeText(prettyStack, COLORS.dim); this._log(type, colorizedStack); } else if (stack) { const prettyStack = this._formatStackTrace(stack.join("\n"), 1); - const colorizedStack = this._colorizeText(prettyStack, "\x1B[2m" /* dim */); + const colorizedStack = this._colorizeText(prettyStack, COLORS.dim); this._log(type, colorizedStack); } else { throw new Error("Stack is null"); @@ -73,7 +103,7 @@ var PrettyLogs = class { if (!color) { throw new Error(`Invalid color: ${color}`); } - return color.concat(text).concat("\x1B[0m" /* reset */); + return color.concat(text).concat(COLORS.reset); } _formatStackTrace(stack, linesToRemove = 0, prefix = "") { const lines = stack.split("\n"); @@ -92,25 +122,23 @@ var PrettyLogs = class { error: "\u26A0", info: "\u203A", debug: "\u203A\u203A", - verbose: "\u{1F4AC}", + verbose: "\u{1F4AC}" }; const symbol = defaultSymbols[type]; const messageFormatted = typeof message === "string" ? message : util.inspect(message, { showHidden: true, depth: null, breakLength: Infinity }); const lines = messageFormatted.split("\n"); - const logString = lines - .map((line, index) => { - const prefix = index === 0 ? ` ${symbol}` : ` ${" ".repeat(symbol.length)}`; - return `${prefix} ${line}`; - }) - .join("\n"); + const logString = lines.map((line, index) => { + const prefix = index === 0 ? ` ${symbol}` : ` ${" ".repeat(symbol.length)}`; + return `${prefix} ${line}`; + }).join("\n"); const fullLogString = logString; const colorMap = { - fatal: ["error", "\x1B[31m" /* fgRed */], - ok: ["log", "\x1B[32m" /* fgGreen */], - error: ["warn", "\x1B[33m" /* fgYellow */], - info: ["info", "\x1B[2m" /* dim */], - debug: ["debug", "\x1B[35m" /* fgMagenta */], - verbose: ["debug", "\x1B[2m" /* dim */], + fatal: ["error", COLORS.fgRed], + ok: ["log", COLORS.fgGreen], + error: ["warn", COLORS.fgYellow], + info: ["info", COLORS.dim], + debug: ["debug", COLORS.fgMagenta], + verbose: ["debug", COLORS.dim] }; const _console = console[colorMap[type][0]]; if (typeof _console === "function") { @@ -121,7 +149,7 @@ var PrettyLogs = class { } }; -// src/supabase/helpers/tables/logs.ts +// src/supabase/types/logs.ts var LogReturn = class { logMessage; metadata; @@ -130,36 +158,21 @@ var LogReturn = class { this.metadata = metadata; } }; + +// src/supabase/helpers/tables/logs.ts var Logs = class _Logs { - _supabase; - _context = null; _maxLevel = -1; - _queue = []; - // Your log queue - _concurrency = 6; - // Maximum concurrent requests - _retryDelay = 1e3; - // Delay between retries in milliseconds - _throttleCount = 0; - _retryLimit = 0; - // Retries disabled by default static console; - _log({ level, consoleLog, logMessage, metadata, postComment, type }) { - if (this._getNumericLevel(level) > this._maxLevel) return null; + _log({ level, consoleLog, logMessage, metadata, type }) { + if (this._getNumericLevel(level) > this._maxLevel) + return null; consoleLog(logMessage, metadata || void 0); - if (this._context && postComment) { - const colorizedCommentMessage = this._diffColorCommentMessage(type, logMessage); - const commentMetaData = metadata ? _Logs._commentMetaData(metadata, level) : null; - this._postComment(metadata ? [colorizedCommentMessage, commentMetaData].join("\n") : colorizedCommentMessage); - } - const toSupabase = { log: logMessage, level, metadata }; - this._save(toSupabase); return new LogReturn( { raw: logMessage, diff: this._diffColorCommentMessage(type, logMessage), type, - level, + level }, metadata ); @@ -179,52 +192,50 @@ var Logs = class _Logs { metadata.caller = match[1]; } } - const gitCommit = COMMIT_HASH?.substring(0, 7) ?? null; - metadata.revision = gitCommit; return metadata; } ok(log, metadata, postComment) { metadata = this._addDiagnosticInformation(metadata); return this._log({ - level: "info" /* INFO */, + level: LOG_LEVEL.INFO, consoleLog: _Logs.console.ok, logMessage: log, metadata, postComment, - type: "ok", + type: "ok" }); } info(log, metadata, postComment) { metadata = this._addDiagnosticInformation(metadata); return this._log({ - level: "info" /* INFO */, + level: LOG_LEVEL.INFO, consoleLog: _Logs.console.info, logMessage: log, metadata, postComment, - type: "info", + type: "info" }); } error(log, metadata, postComment) { metadata = this._addDiagnosticInformation(metadata); return this._log({ - level: "error" /* ERROR */, + level: LOG_LEVEL.ERROR, consoleLog: _Logs.console.error, logMessage: log, metadata, postComment, - type: "error", + type: "error" }); } debug(log, metadata, postComment) { metadata = this._addDiagnosticInformation(metadata); return this._log({ - level: "debug" /* DEBUG */, + level: LOG_LEVEL.DEBUG, consoleLog: _Logs.console.debug, logMessage: log, metadata, postComment, - type: "debug", + type: "debug" }); } fatal(log, metadata, postComment) { @@ -242,96 +253,33 @@ var Logs = class _Logs { } metadata = this._addDiagnosticInformation(metadata); return this._log({ - level: "fatal" /* FATAL */, + level: LOG_LEVEL.FATAL, consoleLog: _Logs.console.fatal, logMessage: log, metadata, postComment, - type: "fatal", + type: "fatal" }); } verbose(log, metadata, postComment) { metadata = this._addDiagnosticInformation(metadata); return this._log({ - level: "verbose" /* VERBOSE */, + level: LOG_LEVEL.VERBOSE, consoleLog: _Logs.console.verbose, logMessage: log, metadata, postComment, - type: "verbose", + type: "verbose" }); } - constructor(supabase, retryLimit, logLevel, context) { - this._supabase = supabase; - this._context = context; - this._retryLimit = retryLimit; + constructor(logLevel) { this._maxLevel = this._getNumericLevel(logLevel); _Logs.console = new PrettyLogs(); } - async _sendLogsToSupabase(log) { - const { error } = await this._supabase.from("logs").insert(log); - if (error) throw _Logs.console.fatal("Error logging to Supabase:", error); - } - async _processLogs(log) { - try { - await this._sendLogsToSupabase(log); - } catch (error) { - _Logs.console.fatal("Error sending log, retrying:", error); - return this._retryLimit > 0 ? await this._retryLog(log) : null; - } - } - async _retryLog(log, retryCount = 0) { - if (retryCount >= this._retryLimit) { - _Logs.console.fatal("Max retry limit reached for log:", log); - return; - } - await new Promise((resolve) => setTimeout(resolve, this._retryDelay)); - try { - await this._sendLogsToSupabase(log); - } catch (error) { - _Logs.console.fatal("Error sending log (after retry):", error); - await this._retryLog(log, retryCount + 1); - } - } - async _processLogQueue() { - while (this._queue.length > 0) { - const log = this._queue.shift(); - if (!log) { - continue; - } - await this._processLogs(log); - } - } - async _throttle() { - if (this._throttleCount >= this._concurrency) { - return; - } - this._throttleCount++; - try { - await this._processLogQueue(); - } finally { - this._throttleCount--; - if (this._queue.length > 0) { - await this._throttle(); - } - } - } - async _addToQueue(log) { - this._queue.push(log); - if (this._throttleCount < this._concurrency) { - await this._throttle(); - } - } - _save(logInsert) { - this._addToQueue(logInsert) - .then(() => void 0) - .catch(() => _Logs.console.fatal("Error adding logs to queue")); - _Logs.console.ok(logInsert.log, logInsert); - } static _commentMetaData(metadata, level) { _Logs.console.debug("the main place that metadata is being serialized as an html comment"); const prettySerialized = JSON.stringify(metadata, null, 2); - if (level === "fatal" /* FATAL */) { + if (level === LOG_LEVEL.FATAL) { return ["```json", prettySerialized, "```"].join("\n"); } else { return [""].join("\n"); @@ -343,7 +291,7 @@ var Logs = class _Logs { // - text in red ok: "+", // + text in green - error: "!", + error: "!" // ! text in orange // info: "#", // # text in gray // debug: "@@@@",// @@ text in purple (and bold)@@ @@ -355,48 +303,27 @@ var Logs = class _Logs { }; const selected = diffPrefix[type]; if (selected) { - message = message - .trim() - .split("\n") - .map((line) => `${selected} ${line}`) - .join("\n"); + message = message.trim().split("\n").map((line) => `${selected} ${line}`).join("\n"); } else if (type === "debug") { - message = message - .split("\n") - .map((line) => `@@ ${line} @@`) - .join("\n"); + message = message.split("\n").map((line) => `@@ ${line} @@`).join("\n"); } else { - message = message - .split("\n") - .map((line) => `# ${line}`) - .join("\n"); + message = message.split("\n").map((line) => `# ${line}`).join("\n"); } const diffHeader = "```diff"; const diffFooter = "```"; return [diffHeader, message, diffFooter].join("\n"); } - _postComment(message) { - if (!this._context) return; - this._context.octokit.issues - .createComment({ - owner: this._context.issue().owner, - repo: this._context.issue().repo, - issue_number: this._context.issue().issue_number, - body: message, - }) - .catch((x) => console.trace(x)); - } _getNumericLevel(level) { switch (level) { - case "fatal" /* FATAL */: + case LOG_LEVEL.FATAL: return 0; - case "error" /* ERROR */: + case LOG_LEVEL.ERROR: return 1; - case "info" /* INFO */: + case LOG_LEVEL.INFO: return 2; - case "verbose" /* VERBOSE */: + case LOG_LEVEL.VERBOSE: return 4; - case "debug" /* DEBUG */: + case LOG_LEVEL.DEBUG: return 5; default: return -1; @@ -407,7 +334,7 @@ var Logs = class _Logs { return { message: obj.message, name: obj.name, - stack: obj.stack ? obj.stack.split("\n") : null, + stack: obj.stack ? obj.stack.split("\n") : null }; } else if (typeof obj === "object" && obj !== null) { const keys = Object.keys(obj); @@ -418,5 +345,7 @@ var Logs = class _Logs { return obj; } }; -export { LogReturn, Logs }; -//# sourceMappingURL=logs.js.map +export { + Logs +}; +//# sourceMappingURL=logs.js.map \ No newline at end of file diff --git a/dist/logs.js.map b/dist/logs.js.map index 8ebde91..76bbebe 100644 --- a/dist/logs.js.map +++ b/dist/logs.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/commit-hash.ts","../src/supabase/helpers/tables/pretty-logs.ts","../src/supabase/helpers/tables/logs.ts"],"sourcesContent":["import { execSync } from \"child_process\";\nexport let COMMIT_HASH: null | string = null; // \"0000000000000000000000000000000000000000\";\n\ntry {\n COMMIT_HASH = execSync(\"git rev-parse --short HEAD\").toString().trim();\n} catch (e) {\n // netlify has no git binary\n}\n","import util from \"util\";\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-explicit-any */\ntype PrettyLogsWithOk = \"ok\" | LogLevel;\nexport class PrettyLogs {\n constructor() {\n this.ok = this.ok.bind(this);\n this.info = this.info.bind(this);\n this.error = this.error.bind(this);\n this.fatal = this.fatal.bind(this);\n this.debug = this.debug.bind(this);\n this.verbose = this.verbose.bind(this);\n }\n public fatal(message: string, metadata?: any) {\n this._logWithStack(LogLevel.FATAL, message, metadata);\n }\n\n public error(message: string, metadata?: any) {\n this._logWithStack(LogLevel.ERROR, message, metadata);\n }\n\n public ok(message: string, metadata?: any) {\n this._logWithStack(\"ok\", message, metadata);\n }\n\n public info(message: string, metadata?: any) {\n this._logWithStack(LogLevel.INFO, message, metadata);\n }\n\n public debug(message: string, metadata?: any) {\n this._logWithStack(LogLevel.DEBUG, message, metadata);\n }\n\n public verbose(message: string, metadata?: any) {\n this._logWithStack(LogLevel.VERBOSE, message, metadata);\n }\n\n private _logWithStack(type: \"ok\" | LogLevel, message: string, metadata?: Metadata | string) {\n this._log(type, message);\n if (typeof metadata === \"string\") {\n this._log(type, metadata);\n return;\n }\n if (metadata) {\n let stack = metadata?.error?.stack || metadata?.stack;\n if (!stack) {\n // generate and remove the top four lines of the stack trace\n const stackTrace = new Error().stack?.split(\"\\n\");\n if (stackTrace) {\n stackTrace.splice(0, 4);\n stack = stackTrace.filter((line) => line.includes(\".ts:\")).join(\"\\n\");\n }\n }\n const newMetadata = { ...metadata };\n delete newMetadata.message;\n delete newMetadata.name;\n delete newMetadata.stack;\n\n if (!this._isEmpty(newMetadata)) {\n this._log(type, newMetadata);\n }\n\n if (typeof stack == \"string\") {\n const prettyStack = this._formatStackTrace(stack, 1);\n const colorizedStack = this._colorizeText(prettyStack, Colors.dim);\n this._log(type, colorizedStack);\n } else if (stack) {\n const prettyStack = this._formatStackTrace((stack as unknown as string[]).join(\"\\n\"), 1);\n const colorizedStack = this._colorizeText(prettyStack, Colors.dim);\n this._log(type, colorizedStack);\n } else {\n throw new Error(\"Stack is null\");\n }\n }\n }\n\n private _colorizeText(text: string, color: Colors): string {\n if (!color) {\n throw new Error(`Invalid color: ${color}`);\n }\n return color.concat(text).concat(Colors.reset);\n }\n\n private _formatStackTrace(stack: string, linesToRemove = 0, prefix = \"\"): string {\n const lines = stack.split(\"\\n\");\n for (let i = 0; i < linesToRemove; i++) {\n lines.shift(); // Remove the top line\n }\n return lines\n .map((line) => `${prefix}${line.replace(/\\s*at\\s*/, \" ↳ \")}`) // Replace 'at' and prefix every line\n .join(\"\\n\");\n }\n\n private _isEmpty(obj: Record) {\n return !Reflect.ownKeys(obj).some((key) => typeof obj[String(key)] !== \"function\");\n }\n\n private _log(type: PrettyLogsWithOk, message: any) {\n const defaultSymbols: Record = {\n fatal: \"×\",\n ok: \"✓\",\n error: \"⚠\",\n info: \"›\",\n debug: \"››\",\n verbose: \"💬\",\n };\n\n const symbol = defaultSymbols[type];\n\n // Formatting the message\n const messageFormatted = typeof message === \"string\" ? message : util.inspect(message, { showHidden: true, depth: null, breakLength: Infinity });\n // const messageFormatted =\n // typeof message === \"string\" ? message : JSON.stringify(Logs.convertErrorsIntoObjects(message));\n\n // Constructing the full log string with the prefix symbol\n const lines = messageFormatted.split(\"\\n\");\n const logString = lines\n .map((line, index) => {\n // Add the symbol only to the first line and keep the indentation for the rest\n const prefix = index === 0 ? `\\t${symbol}` : `\\t${\" \".repeat(symbol.length)}`;\n return `${prefix} ${line}`;\n })\n .join(\"\\n\");\n\n const fullLogString = logString;\n\n const colorMap: Record = {\n fatal: [\"error\", Colors.fgRed],\n ok: [\"log\", Colors.fgGreen],\n error: [\"warn\", Colors.fgYellow],\n info: [\"info\", Colors.dim],\n debug: [\"debug\", Colors.fgMagenta],\n verbose: [\"debug\", Colors.dim],\n };\n\n const _console = console[colorMap[type][0] as keyof typeof console] as (...args: string[]) => void;\n if (typeof _console === \"function\") {\n _console(this._colorizeText(fullLogString, colorMap[type][1]));\n } else {\n throw new Error(fullLogString);\n }\n }\n}\ninterface Metadata {\n error?: { stack?: string };\n stack?: string;\n message?: string;\n name?: string;\n [key: string]: any;\n}\n\nenum Colors {\n reset = \"\\x1b[0m\",\n bright = \"\\x1b[1m\",\n dim = \"\\x1b[2m\",\n underscore = \"\\x1b[4m\",\n blink = \"\\x1b[5m\",\n reverse = \"\\x1b[7m\",\n hidden = \"\\x1b[8m\",\n\n fgBlack = \"\\x1b[30m\",\n fgRed = \"\\x1b[31m\",\n fgGreen = \"\\x1b[32m\",\n fgYellow = \"\\x1b[33m\",\n fgBlue = \"\\x1b[34m\",\n fgMagenta = \"\\x1b[35m\",\n fgCyan = \"\\x1b[36m\",\n fgWhite = \"\\x1b[37m\",\n\n bgBlack = \"\\x1b[40m\",\n bgRed = \"\\x1b[41m\",\n bgGreen = \"\\x1b[42m\",\n bgYellow = \"\\x1b[43m\",\n bgBlue = \"\\x1b[44m\",\n bgMagenta = \"\\x1b[45m\",\n bgCyan = \"\\x1b[46m\",\n bgWhite = \"\\x1b[47m\",\n}\nexport enum LogLevel {\n FATAL = \"fatal\",\n ERROR = \"error\",\n INFO = \"info\",\n VERBOSE = \"verbose\",\n DEBUG = \"debug\",\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n// This is disabled because logs should be able to log any type of data\n// Normally this is forbidden\n\nimport { SupabaseClient } from \"@supabase/supabase-js\";\nimport { Context as ProbotContext } from \"probot\";\nimport { COMMIT_HASH } from \"../../../commit-hash\";\nimport { Database } from \"../../types/database\";\n\nimport { LogLevel, PrettyLogs } from \"./pretty-logs\";\n\ntype LogFunction = (message: string, metadata?: any) => void;\ntype LogInsert = Database[\"public\"][\"Tables\"][\"logs\"][\"Insert\"];\ntype LogParams = {\n level: LogLevel;\n consoleLog: LogFunction;\n logMessage: string;\n metadata?: any;\n postComment?: boolean;\n type: PublicMethods;\n};\nexport class LogReturn {\n logMessage: LogMessage;\n metadata?: any;\n\n constructor(logMessage: LogMessage, metadata?: any) {\n this.logMessage = logMessage;\n this.metadata = metadata;\n }\n}\n\ntype FunctionPropertyNames = {\n [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n}[keyof T];\n\ntype PublicMethods = Exclude, \"constructor\" | keyof object>;\n\nexport type LogMessage = { raw: string; diff: string; level: LogLevel; type: PublicMethods };\n\nexport class Logs {\n private _supabase: SupabaseClient;\n private _context: ProbotContext | null = null;\n\n private _maxLevel = -1;\n private _queue: LogInsert[] = []; // Your log queue\n private _concurrency = 6; // Maximum concurrent requests\n private _retryDelay = 1000; // Delay between retries in milliseconds\n private _throttleCount = 0;\n private _retryLimit = 0; // Retries disabled by default\n\n static console: PrettyLogs;\n\n private _log({ level, consoleLog, logMessage, metadata, postComment, type }: LogParams): LogReturn | null {\n if (this._getNumericLevel(level) > this._maxLevel) return null; // filter out more verbose logs according to maxLevel set in config\n\n // needs to generate three versions of the information.\n // they must all first serialize the error object if it exists\n // - the comment to post on supabase (must be raw)\n // - the comment to post on github (must include diff syntax)\n // - the comment to post on the console (must be colorized)\n\n consoleLog(logMessage, metadata || undefined);\n\n if (this._context && postComment) {\n const colorizedCommentMessage = this._diffColorCommentMessage(type, logMessage);\n const commentMetaData = metadata ? Logs._commentMetaData(metadata, level) : null;\n this._postComment(metadata ? [colorizedCommentMessage, commentMetaData].join(\"\\n\") : colorizedCommentMessage);\n }\n\n const toSupabase = { log: logMessage, level, metadata } as LogInsert;\n\n this._save(toSupabase);\n\n return new LogReturn(\n {\n raw: logMessage,\n diff: this._diffColorCommentMessage(type, logMessage),\n type,\n level,\n },\n metadata\n );\n }\n private _addDiagnosticInformation(metadata: any) {\n // this is a utility function to get the name of the function that called the log\n // I have mixed feelings on this because it manipulates metadata later possibly without the developer understanding why and where,\n // but seems useful for the metadata parser to understand where the comment originated from\n\n if (!metadata) {\n metadata = {};\n }\n if (typeof metadata == \"string\" || typeof metadata == \"number\") {\n // TODO: think i need to support every data type\n metadata = { message: metadata };\n }\n\n const stackLines = new Error().stack?.split(\"\\n\") || [];\n if (stackLines.length > 3) {\n const callerLine = stackLines[3]; // .replace(process.cwd(), \"\");\n const match = callerLine.match(/at (\\S+)/);\n if (match) {\n metadata.caller = match[1];\n }\n }\n\n const gitCommit = COMMIT_HASH?.substring(0, 7) ?? null;\n metadata.revision = gitCommit;\n\n return metadata;\n }\n\n public ok(log: string, metadata?: any, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LogLevel.INFO,\n consoleLog: Logs.console.ok,\n logMessage: log,\n metadata,\n postComment,\n type: \"ok\",\n });\n }\n\n public info(log: string, metadata?: any, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LogLevel.INFO,\n consoleLog: Logs.console.info,\n logMessage: log,\n metadata,\n postComment,\n type: \"info\",\n });\n }\n\n public error(log: string, metadata?: any, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LogLevel.ERROR,\n consoleLog: Logs.console.error,\n logMessage: log,\n metadata,\n postComment,\n type: \"error\",\n });\n }\n\n public debug(log: string, metadata?: any, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LogLevel.DEBUG,\n consoleLog: Logs.console.debug,\n logMessage: log,\n metadata,\n postComment,\n type: \"debug\",\n });\n }\n\n public fatal(log: string, metadata?: any, postComment?: boolean): LogReturn | null {\n if (!metadata) {\n metadata = Logs.convertErrorsIntoObjects(new Error(log));\n const stack = metadata.stack as string[];\n stack.splice(1, 1);\n metadata.stack = stack;\n }\n if (metadata instanceof Error) {\n metadata = Logs.convertErrorsIntoObjects(metadata);\n const stack = metadata.stack as string[];\n stack.splice(1, 1);\n metadata.stack = stack;\n }\n\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LogLevel.FATAL,\n consoleLog: Logs.console.fatal,\n logMessage: log,\n metadata,\n postComment,\n type: \"fatal\",\n });\n }\n\n verbose(log: string, metadata?: any, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LogLevel.VERBOSE,\n consoleLog: Logs.console.verbose,\n logMessage: log,\n metadata,\n postComment,\n type: \"verbose\",\n });\n }\n\n constructor(supabase: SupabaseClient, retryLimit: number, logLevel: LogLevel, context: ProbotContext | null) {\n this._supabase = supabase;\n this._context = context;\n this._retryLimit = retryLimit;\n this._maxLevel = this._getNumericLevel(logLevel);\n Logs.console = new PrettyLogs();\n }\n\n private async _sendLogsToSupabase(log: LogInsert) {\n const { error } = await this._supabase.from(\"logs\").insert(log);\n if (error) throw Logs.console.fatal(\"Error logging to Supabase:\", error);\n }\n\n private async _processLogs(log: LogInsert) {\n try {\n await this._sendLogsToSupabase(log);\n } catch (error) {\n Logs.console.fatal(\"Error sending log, retrying:\", error);\n return this._retryLimit > 0 ? await this._retryLog(log) : null;\n }\n }\n\n private async _retryLog(log: LogInsert, retryCount = 0) {\n if (retryCount >= this._retryLimit) {\n Logs.console.fatal(\"Max retry limit reached for log:\", log);\n return;\n }\n\n await new Promise((resolve) => setTimeout(resolve, this._retryDelay));\n\n try {\n await this._sendLogsToSupabase(log);\n } catch (error) {\n Logs.console.fatal(\"Error sending log (after retry):\", error);\n await this._retryLog(log, retryCount + 1);\n }\n }\n\n private async _processLogQueue() {\n while (this._queue.length > 0) {\n const log = this._queue.shift();\n if (!log) {\n continue;\n }\n await this._processLogs(log);\n }\n }\n\n private async _throttle() {\n if (this._throttleCount >= this._concurrency) {\n return;\n }\n\n this._throttleCount++;\n try {\n await this._processLogQueue();\n } finally {\n this._throttleCount--;\n if (this._queue.length > 0) {\n await this._throttle();\n }\n }\n }\n\n private async _addToQueue(log: LogInsert) {\n this._queue.push(log);\n if (this._throttleCount < this._concurrency) {\n await this._throttle();\n }\n }\n\n private _save(logInsert: LogInsert) {\n this._addToQueue(logInsert)\n .then(() => void 0)\n .catch(() => Logs.console.fatal(\"Error adding logs to queue\"));\n\n Logs.console.ok(logInsert.log, logInsert);\n }\n\n static _commentMetaData(metadata: any, level: LogLevel) {\n Logs.console.debug(\"the main place that metadata is being serialized as an html comment\");\n const prettySerialized = JSON.stringify(metadata, null, 2);\n // first check if metadata is an error, then post it as a json comment\n // otherwise post it as an html comment\n if (level === LogLevel.FATAL) {\n return [\"```json\", prettySerialized, \"```\"].join(\"\\n\");\n } else {\n return [\"\"].join(\"\\n\");\n }\n }\n\n private _diffColorCommentMessage(type: string, message: string) {\n const diffPrefix = {\n fatal: \"-\", // - text in red\n ok: \"+\", // + text in green\n error: \"!\", // ! text in orange\n // info: \"#\", // # text in gray\n // debug: \"@@@@\",// @@ text in purple (and bold)@@\n // error: null,\n // warn: null,\n // info: null,\n // verbose: \"#\",\n // debug: \"#\",\n };\n const selected = diffPrefix[type as keyof typeof diffPrefix];\n\n if (selected) {\n message = message\n .trim() // Remove leading and trailing whitespace\n .split(\"\\n\")\n .map((line) => `${selected} ${line}`)\n .join(\"\\n\");\n } else if (type === \"debug\") {\n // debug has special formatting\n message = message\n .split(\"\\n\")\n .map((line) => `@@ ${line} @@`)\n .join(\"\\n\"); // debug: \"@@@@\",\n } else {\n // default to gray\n message = message\n .split(\"\\n\")\n .map((line) => `# ${line}`)\n .join(\"\\n\");\n }\n\n const diffHeader = \"```diff\";\n const diffFooter = \"```\";\n\n return [diffHeader, message, diffFooter].join(\"\\n\");\n }\n\n private _postComment(message: string) {\n // post on issue\n if (!this._context) return;\n this._context.octokit.issues\n .createComment({\n owner: this._context.issue().owner,\n repo: this._context.issue().repo,\n issue_number: this._context.issue().issue_number,\n body: message,\n })\n // .then((x) => console.trace(x))\n .catch((x) => console.trace(x));\n }\n\n private _getNumericLevel(level: LogLevel) {\n switch (level) {\n case LogLevel.FATAL:\n return 0;\n case LogLevel.ERROR:\n return 1;\n case LogLevel.INFO:\n return 2;\n case LogLevel.VERBOSE:\n return 4;\n case LogLevel.DEBUG:\n return 5;\n default:\n return -1; // Invalid level\n }\n }\n static convertErrorsIntoObjects(obj: any): any {\n // this is a utility function to render native errors in the console, the database, and on GitHub.\n if (obj instanceof Error) {\n return {\n message: obj.message,\n name: obj.name,\n stack: obj.stack ? obj.stack.split(\"\\n\") : null,\n };\n } else if (typeof obj === \"object\" && obj !== null) {\n const keys = Object.keys(obj);\n keys.forEach((key) => {\n obj[key] = this.convertErrorsIntoObjects(obj[key]);\n });\n }\n return obj;\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAClB,IAAI,cAA6B;AAExC,IAAI;AACF,gBAAc,SAAS,4BAA4B,EAAE,SAAS,EAAE,KAAK;AACvE,SAAS,GAAG;AAEZ;;;ACPA,OAAO,UAAU;AAIV,IAAM,aAAN,MAAiB;AAAA,EACtB,cAAc;AACZ,SAAK,KAAK,KAAK,GAAG,KAAK,IAAI;AAC3B,SAAK,OAAO,KAAK,KAAK,KAAK,IAAI;AAC/B,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,UAAU,KAAK,QAAQ,KAAK,IAAI;AAAA,EACvC;AAAA,EACO,MAAM,SAAiB,UAAgB;AAC5C,SAAK,cAAc,qBAAgB,SAAS,QAAQ;AAAA,EACtD;AAAA,EAEO,MAAM,SAAiB,UAAgB;AAC5C,SAAK,cAAc,qBAAgB,SAAS,QAAQ;AAAA,EACtD;AAAA,EAEO,GAAG,SAAiB,UAAgB;AACzC,SAAK,cAAc,MAAM,SAAS,QAAQ;AAAA,EAC5C;AAAA,EAEO,KAAK,SAAiB,UAAgB;AAC3C,SAAK,cAAc,mBAAe,SAAS,QAAQ;AAAA,EACrD;AAAA,EAEO,MAAM,SAAiB,UAAgB;AAC5C,SAAK,cAAc,qBAAgB,SAAS,QAAQ;AAAA,EACtD;AAAA,EAEO,QAAQ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AAiB;AAEpC,QAAI,CAAC,KAAK;AAAU;AACpB,SAAK,SAAS,QAAQ,OACnB,cAAc;AAAA,MACb,OAAO,KAAK,SAAS,MAAM,EAAE;AAAA,MAC7B,MAAM,KAAK,SAAS,MAAM,EAAE;AAAA,MAC5B,cAAc,KAAK,SAAS,MAAM,EAAE;AAAA,MACpC,MAAM;AAAA,IACR,CAAC,EAEA,MAAM,CAAC,MAAM,QAAQ,MAAM,CAAC,CAAC;AAAA,EAClC;AAAA,EAEQ,iBAAiB,OAAiB;AACxC,YAAQ,OAAO;AAAA,MACb;AACE,eAAO;AAAA,MACT;AACE,eAAO;AAAA,MACT;AACE,eAAO;AAAA,MACT;AACE,eAAO;AAAA,MACT;AACE,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO,yBAAyB,KAAe;AAE7C,QAAI,eAAe,OAAO;AACxB,aAAO;AAAA,QACL,SAAS,IAAI;AAAA,QACb,MAAM,IAAI;AAAA,QACV,OAAO,IAAI,QAAQ,IAAI,MAAM,MAAM,IAAI,IAAI;AAAA,MAC7C;AAAA,IACF,WAAW,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAClD,YAAM,OAAO,OAAO,KAAK,GAAG;AAC5B,WAAK,QAAQ,CAAC,QAAQ;AACpB,YAAI,GAAG,IAAI,KAAK,yBAAyB,IAAI,GAAG,CAAC;AAAA,MACnD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;","names":[]} \ No newline at end of file +{"version":3,"sources":["../src/supabase/helpers/tables/pretty-logs.ts","../src/supabase/constants.ts","../src/supabase/types/logs.ts","../src/supabase/helpers/tables/logs.ts"],"sourcesContent":["import util from \"util\";\nimport { Colors, Metadata, PrettyLogsWithOk } from \"../../types/logs\";\nimport { COLORS, LOG_LEVEL } from \"../../constants\";\n\nexport class PrettyLogs {\n constructor() {\n this.ok = this.ok.bind(this);\n this.info = this.info.bind(this);\n this.error = this.error.bind(this);\n this.fatal = this.fatal.bind(this);\n this.debug = this.debug.bind(this);\n this.verbose = this.verbose.bind(this);\n }\n public fatal(message: string, metadata?: Metadata | string | unknown) {\n this._logWithStack(LOG_LEVEL.FATAL, message, metadata);\n }\n\n public error(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.ERROR, message, metadata);\n }\n\n public ok(message: string, metadata?: Metadata | string) {\n this._logWithStack(\"ok\", message, metadata);\n }\n\n public info(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.INFO, message, metadata);\n }\n\n public debug(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.DEBUG, message, metadata);\n }\n\n public verbose(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.VERBOSE, message, metadata);\n }\n\n private _logWithStack(type: PrettyLogsWithOk, message: string, metaData?: Metadata | string | unknown) {\n this._log(type, message);\n if (typeof metaData === \"string\") {\n this._log(type, metaData);\n return;\n }\n if (metaData) {\n const metadata = metaData as Metadata;\n let stack = metadata?.error?.stack || metadata?.stack;\n if (!stack) {\n // generate and remove the top four lines of the stack trace\n const stackTrace = new Error().stack?.split(\"\\n\");\n if (stackTrace) {\n stackTrace.splice(0, 4);\n stack = stackTrace.filter((line) => line.includes(\".ts:\")).join(\"\\n\");\n }\n }\n const newMetadata = { ...metadata };\n delete newMetadata.message;\n delete newMetadata.name;\n delete newMetadata.stack;\n\n if (!this._isEmpty(newMetadata)) {\n this._log(type, newMetadata);\n }\n\n if (typeof stack == \"string\") {\n const prettyStack = this._formatStackTrace(stack, 1);\n const colorizedStack = this._colorizeText(prettyStack, COLORS.dim);\n this._log(type, colorizedStack);\n } else if (stack) {\n const prettyStack = this._formatStackTrace((stack as unknown as string[]).join(\"\\n\"), 1);\n const colorizedStack = this._colorizeText(prettyStack, COLORS.dim);\n this._log(type, colorizedStack);\n } else {\n throw new Error(\"Stack is null\");\n }\n }\n }\n\n private _colorizeText(text: string, color: Colors): string {\n if (!color) {\n throw new Error(`Invalid color: ${color}`);\n }\n return color.concat(text).concat(COLORS.reset);\n }\n\n private _formatStackTrace(stack: string, linesToRemove = 0, prefix = \"\"): string {\n const lines = stack.split(\"\\n\");\n for (let i = 0; i < linesToRemove; i++) {\n lines.shift(); // Remove the top line\n }\n return lines\n .map((line) => `${prefix}${line.replace(/\\s*at\\s*/, \" ↳ \")}`) // Replace 'at' and prefix every line\n .join(\"\\n\");\n }\n\n private _isEmpty(obj: Record) {\n return !Reflect.ownKeys(obj).some((key) => typeof obj[String(key)] !== \"function\");\n }\n\n private _log(type: PrettyLogsWithOk, message: string | Record) {\n const defaultSymbols: Record = {\n fatal: \"×\",\n ok: \"✓\",\n error: \"⚠\",\n info: \"›\",\n debug: \"››\",\n verbose: \"💬\",\n };\n\n const symbol = defaultSymbols[type];\n\n // Formatting the message\n const messageFormatted = typeof message === \"string\" ? message : util.inspect(message, { showHidden: true, depth: null, breakLength: Infinity });\n // const messageFormatted =\n // typeof message === \"string\" ? message : JSON.stringify(Logs.convertErrorsIntoObjects(message));\n\n // Constructing the full log string with the prefix symbol\n const lines = messageFormatted.split(\"\\n\");\n const logString = lines\n .map((line, index) => {\n // Add the symbol only to the first line and keep the indentation for the rest\n const prefix = index === 0 ? `\\t${symbol}` : `\\t${\" \".repeat(symbol.length)}`;\n return `${prefix} ${line}`;\n })\n .join(\"\\n\");\n\n const fullLogString = logString;\n\n const colorMap: Record = {\n fatal: [\"error\", COLORS.fgRed],\n ok: [\"log\", COLORS.fgGreen],\n error: [\"warn\", COLORS.fgYellow],\n info: [\"info\", COLORS.dim],\n debug: [\"debug\", COLORS.fgMagenta],\n verbose: [\"debug\", COLORS.dim],\n };\n\n const _console = console[colorMap[type][0] as keyof typeof console] as (...args: string[]) => void;\n if (typeof _console === \"function\") {\n _console(this._colorizeText(fullLogString, colorMap[type][1]));\n } else {\n throw new Error(fullLogString);\n }\n }\n}\n","export const COLORS = {\n reset: \"\\x1b[0m\",\n bright: \"\\x1b[1m\",\n dim: \"\\x1b[2m\",\n underscore: \"\\x1b[4m\",\n blink: \"\\x1b[5m\",\n reverse: \"\\x1b[7m\",\n hidden: \"\\x1b[8m\",\n\n fgBlack: \"\\x1b[30m\",\n fgRed: \"\\x1b[31m\",\n fgGreen: \"\\x1b[32m\",\n fgYellow: \"\\x1b[33m\",\n fgBlue: \"\\x1b[34m\",\n fgMagenta: \"\\x1b[35m\",\n fgCyan: \"\\x1b[36m\",\n fgWhite: \"\\x1b[37m\",\n\n bgBlack: \"\\x1b[40m\",\n bgRed: \"\\x1b[41m\",\n bgGreen: \"\\x1b[42m\",\n bgYellow: \"\\x1b[43m\",\n bgBlue: \"\\x1b[44m\",\n bgMagenta: \"\\x1b[45m\",\n bgCyan: \"\\x1b[46m\",\n bgWhite: \"\\x1b[47m\",\n} as const;\n\nexport const LOG_LEVEL = {\n FATAL: \"fatal\",\n ERROR: \"error\",\n INFO: \"info\",\n VERBOSE: \"verbose\",\n DEBUG: \"debug\",\n} as const;\n","import { COLORS, LOG_LEVEL } from \"../constants\";\nimport { Database } from \"./database\";\n\ntype LogFunction = (message: string, metadata?: Metadata) => void;\nexport type Colors = (typeof COLORS)[keyof typeof COLORS];\nexport type LogLevel = (typeof LOG_LEVEL)[keyof typeof LOG_LEVEL];\nexport type PrettyLogsWithOk = \"ok\" | LogLevel;\nexport type LogInsert = Database[\"public\"][\"Tables\"][\"logs\"][\"Insert\"];\nexport type LogMessage = { raw: string; diff: string; level: LogLevel; type: PrettyLogsWithOk };\n\nexport type LogParams = {\n level: LogLevel;\n consoleLog: LogFunction;\n logMessage: string;\n metadata?: Metadata;\n postComment?: boolean;\n type: PrettyLogsWithOk;\n};\n\nexport interface Metadata {\n error?: { stack?: string };\n stack?: string | string[] | null;\n message?: string;\n name?: string;\n [key: string]: unknown;\n}\n\nexport class LogReturn {\n logMessage: LogMessage;\n metadata?: Metadata;\n\n constructor(logMessage: LogMessage, metadata?: Metadata) {\n this.logMessage = logMessage;\n this.metadata = metadata;\n }\n}\n","import { PrettyLogs } from \"./pretty-logs\";\nimport { LogLevel, LogParams, LogReturn } from \"../../types/logs\";\nimport { LOG_LEVEL } from \"../../constants\";\nimport { Metadata } from \"../../types/logs\";\n\nexport class Logs {\n private _maxLevel = -1;\n static console: PrettyLogs;\n\n private _log({ level, consoleLog, logMessage, metadata, type }: LogParams): LogReturn | null {\n if (this._getNumericLevel(level) > this._maxLevel) return null; // filter out more verbose logs according to maxLevel set in config\n\n // needs to generate three versions of the information.\n // they must all first serialize the error object if it exists\n // - the comment to post on supabase (must be raw)\n // - the comment to post on github (must include diff syntax)\n // - the comment to post on the console (must be colorized)\n\n consoleLog(logMessage, metadata || undefined);\n return new LogReturn(\n {\n raw: logMessage,\n diff: this._diffColorCommentMessage(type, logMessage),\n type,\n level,\n },\n metadata\n );\n }\n\n private _addDiagnosticInformation(metadata: Record | string | number | null | undefined) {\n // this is a utility function to get the name of the function that called the log\n // I have mixed feelings on this because it manipulates metadata later possibly without the developer understanding why and where,\n // but seems useful for the metadata parser to understand where the comment originated from\n\n if (!metadata) {\n metadata = {};\n }\n if (typeof metadata == \"string\" || typeof metadata == \"number\") {\n // TODO: think i need to support every data type\n metadata = { message: metadata };\n }\n\n const stackLines = new Error().stack?.split(\"\\n\") || [];\n if (stackLines.length > 3) {\n const callerLine = stackLines[3]; // .replace(process.cwd(), \"\");\n const match = callerLine.match(/at (\\S+)/);\n if (match) {\n metadata.caller = match[1];\n }\n }\n\n return metadata;\n }\n\n public ok(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LOG_LEVEL.INFO,\n consoleLog: Logs.console.ok,\n logMessage: log,\n metadata,\n postComment,\n type: \"ok\",\n });\n }\n\n public info(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LOG_LEVEL.INFO,\n consoleLog: Logs.console.info,\n logMessage: log,\n metadata,\n postComment,\n type: \"info\",\n });\n }\n\n public error(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LOG_LEVEL.ERROR,\n consoleLog: Logs.console.error,\n logMessage: log,\n metadata,\n postComment,\n type: \"error\",\n });\n }\n\n public debug(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LOG_LEVEL.DEBUG,\n consoleLog: Logs.console.debug,\n logMessage: log,\n metadata,\n postComment,\n type: \"debug\",\n });\n }\n\n public fatal(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null {\n if (!metadata) {\n metadata = Logs.convertErrorsIntoObjects(new Error(log)) as Metadata;\n const stack = metadata.stack as string[];\n stack.splice(1, 1);\n metadata.stack = stack;\n }\n\n if (metadata instanceof Error) {\n metadata = Logs.convertErrorsIntoObjects(metadata) as Metadata;\n const stack = metadata.stack as string[];\n stack.splice(1, 1);\n metadata.stack = stack;\n }\n\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LOG_LEVEL.FATAL,\n consoleLog: Logs.console.fatal,\n logMessage: log,\n metadata,\n postComment,\n type: \"fatal\",\n });\n }\n\n verbose(log: string, metadata?: Metadata, postComment?: boolean): LogReturn | null {\n metadata = this._addDiagnosticInformation(metadata);\n return this._log({\n level: LOG_LEVEL.VERBOSE,\n consoleLog: Logs.console.verbose,\n logMessage: log,\n metadata,\n postComment,\n type: \"verbose\",\n });\n }\n\n constructor(logLevel: LogLevel) {\n this._maxLevel = this._getNumericLevel(logLevel);\n Logs.console = new PrettyLogs();\n }\n\n static _commentMetaData(metadata: Metadata, level: LogLevel) {\n Logs.console.debug(\"the main place that metadata is being serialized as an html comment\");\n const prettySerialized = JSON.stringify(metadata, null, 2);\n // first check if metadata is an error, then post it as a json comment\n // otherwise post it as an html comment\n if (level === LOG_LEVEL.FATAL) {\n return [\"```json\", prettySerialized, \"```\"].join(\"\\n\");\n } else {\n return [\"\"].join(\"\\n\");\n }\n }\n\n private _diffColorCommentMessage(type: string, message: string) {\n const diffPrefix = {\n fatal: \"-\", // - text in red\n ok: \"+\", // + text in green\n error: \"!\", // ! text in orange\n // info: \"#\", // # text in gray\n // debug: \"@@@@\",// @@ text in purple (and bold)@@\n // error: null,\n // warn: null,\n // info: null,\n // verbose: \"#\",\n // debug: \"#\",\n };\n const selected = diffPrefix[type as keyof typeof diffPrefix];\n\n if (selected) {\n message = message\n .trim() // Remove leading and trailing whitespace\n .split(\"\\n\")\n .map((line) => `${selected} ${line}`)\n .join(\"\\n\");\n } else if (type === \"debug\") {\n // debug has special formatting\n message = message\n .split(\"\\n\")\n .map((line) => `@@ ${line} @@`)\n .join(\"\\n\"); // debug: \"@@@@\",\n } else {\n // default to gray\n message = message\n .split(\"\\n\")\n .map((line) => `# ${line}`)\n .join(\"\\n\");\n }\n\n const diffHeader = \"```diff\";\n const diffFooter = \"```\";\n\n return [diffHeader, message, diffFooter].join(\"\\n\");\n }\n\n private _getNumericLevel(level: LogLevel) {\n switch (level) {\n case LOG_LEVEL.FATAL:\n return 0;\n case LOG_LEVEL.ERROR:\n return 1;\n case LOG_LEVEL.INFO:\n return 2;\n case LOG_LEVEL.VERBOSE:\n return 4;\n case LOG_LEVEL.DEBUG:\n return 5;\n default:\n return -1; // Invalid level\n }\n }\n static convertErrorsIntoObjects(obj: unknown): Metadata | unknown {\n // this is a utility function to render native errors in the console, the database, and on GitHub.\n if (obj instanceof Error) {\n return {\n message: obj.message,\n name: obj.name,\n stack: obj.stack ? obj.stack.split(\"\\n\") : null,\n };\n } else if (typeof obj === \"object\" && obj !== null) {\n const keys = Object.keys(obj);\n keys.forEach((key) => {\n obj[key] = this.convertErrorsIntoObjects(obj[key]);\n });\n }\n return obj;\n }\n}\n"],"mappings":";AAAA,OAAO,UAAU;;;ACAV,IAAM,SAAS;AAAA,EACpB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,OAAO;AAAA,E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AAC,SAAS,GAAG,QAAQ,IAAI,IAAI,EAAE,EACnC,KAAK,IAAI;AAAA,IACd,WAAW,SAAS,SAAS;AAE3B,gBAAU,QACP,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,MAAM,IAAI,KAAK,EAC7B,KAAK,IAAI;AAAA,IACd,OAAO;AAEL,gBAAU,QACP,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,EACzB,KAAK,IAAI;AAAA,IACd;AAEA,UAAM,aAAa;AACnB,UAAM,aAAa;AAEnB,WAAO,CAAC,YAAY,SAAS,UAAU,EAAE,KAAK,IAAI;AAAA,EACpD;AAAA,EAEQ,iBAAiB,OAAiB;AACxC,YAAQ,OAAO;AAAA,MACb,KAAK,UAAU;AACb,eAAO;AAAA,MACT,KAAK,UAAU;AACb,eAAO;AAAA,MACT,KAAK,UAAU;AACb,eAAO;AAAA,MACT,KAAK,UAAU;AACb,eAAO;AAAA,MACT,KAAK,UAAU;AACb,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO,yBAAyB,KAAkC;AAEhE,QAAI,eAAe,OAAO;AACxB,aAAO;AAAA,QACL,SAAS,IAAI;AAAA,QACb,MAAM,IAAI;AAAA,QACV,OAAO,IAAI,QAAQ,IAAI,MAAM,MAAM,IAAI,IAAI;AAAA,MAC7C;AAAA,IACF,WAAW,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAClD,YAAM,OAAO,OAAO,KAAK,GAAG;AAC5B,WAAK,QAAQ,CAAC,QAAQ;AACpB,YAAI,GAAG,IAAI,KAAK,yBAAyB,IAAI,GAAG,CAAC;AAAA,MACnD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;","names":[]} \ No newline at end of file diff --git a/dist/pretty-logs-TeMdXxew.d.ts b/dist/pretty-logs-TeMdXxew.d.ts new file mode 100644 index 0000000..92916f6 --- /dev/null +++ b/dist/pretty-logs-TeMdXxew.d.ts @@ -0,0 +1,47 @@ +declare const LOG_LEVEL: { + readonly FATAL: "fatal"; + readonly ERROR: "error"; + readonly INFO: "info"; + readonly VERBOSE: "verbose"; + readonly DEBUG: "debug"; +}; + +type LogLevel = (typeof LOG_LEVEL)[keyof typeof LOG_LEVEL]; +type PrettyLogsWithOk = "ok" | LogLevel; +type LogMessage = { + raw: string; + diff: string; + level: LogLevel; + type: PrettyLogsWithOk; +}; +interface Metadata { + error?: { + stack?: string; + }; + stack?: string | string[] | null; + message?: string; + name?: string; + [key: string]: unknown; +} +declare class LogReturn { + logMessage: LogMessage; + metadata?: Metadata; + constructor(logMessage: LogMessage, metadata?: Metadata); +} + +declare class PrettyLogs { + constructor(); + fatal(message: string, metadata?: Metadata | string | unknown): void; + error(message: string, metadata?: Metadata | string): void; + ok(message: string, metadata?: Metadata | string): void; + info(message: string, metadata?: Metadata | string): void; + debug(message: string, metadata?: Metadata | string): void; + verbose(message: string, metadata?: Metadata | string): void; + private _logWithStack; + private _colorizeText; + private _formatStackTrace; + private _isEmpty; + private _log; +} + +export { LogReturn as L, type Metadata as M, PrettyLogs as P, type LogLevel as a }; diff --git a/dist/pretty-logs.d.ts b/dist/pretty-logs.d.ts index 2939aa7..247d105 100644 --- a/dist/pretty-logs.d.ts +++ b/dist/pretty-logs.d.ts @@ -1,23 +1 @@ -declare class PrettyLogs { - constructor(); - fatal(message: string, metadata?: any): void; - error(message: string, metadata?: any): void; - ok(message: string, metadata?: any): void; - info(message: string, metadata?: any): void; - debug(message: string, metadata?: any): void; - verbose(message: string, metadata?: any): void; - private _logWithStack; - private _colorizeText; - private _formatStackTrace; - private _isEmpty; - private _log; -} -declare enum LogLevel { - FATAL = "fatal", - ERROR = "error", - INFO = "info", - VERBOSE = "verbose", - DEBUG = "debug", -} - -export { LogLevel, PrettyLogs }; +export { P as PrettyLogs } from './pretty-logs-TeMdXxew.js'; diff --git a/dist/pretty-logs.js b/dist/pretty-logs.js index 56fe422..22bd0c8 100644 --- a/dist/pretty-logs.js +++ b/dist/pretty-logs.js @@ -1,5 +1,41 @@ // src/supabase/helpers/tables/pretty-logs.ts import util from "util"; + +// src/supabase/constants.ts +var COLORS = { + reset: "\x1B[0m", + bright: "\x1B[1m", + dim: "\x1B[2m", + underscore: "\x1B[4m", + blink: "\x1B[5m", + reverse: "\x1B[7m", + hidden: "\x1B[8m", + fgBlack: "\x1B[30m", + fgRed: "\x1B[31m", + fgGreen: "\x1B[32m", + fgYellow: "\x1B[33m", + fgBlue: "\x1B[34m", + fgMagenta: "\x1B[35m", + fgCyan: "\x1B[36m", + fgWhite: "\x1B[37m", + bgBlack: "\x1B[40m", + bgRed: "\x1B[41m", + bgGreen: "\x1B[42m", + bgYellow: "\x1B[43m", + bgBlue: "\x1B[44m", + bgMagenta: "\x1B[45m", + bgCyan: "\x1B[46m", + bgWhite: "\x1B[47m" +}; +var LOG_LEVEL = { + FATAL: "fatal", + ERROR: "error", + INFO: "info", + VERBOSE: "verbose", + DEBUG: "debug" +}; + +// src/supabase/helpers/tables/pretty-logs.ts var PrettyLogs = class { constructor() { this.ok = this.ok.bind(this); @@ -10,30 +46,31 @@ var PrettyLogs = class { this.verbose = this.verbose.bind(this); } fatal(message, metadata) { - this._logWithStack("fatal" /* FATAL */, message, metadata); + this._logWithStack(LOG_LEVEL.FATAL, message, metadata); } error(message, metadata) { - this._logWithStack("error" /* ERROR */, message, metadata); + this._logWithStack(LOG_LEVEL.ERROR, message, metadata); } ok(message, metadata) { this._logWithStack("ok", message, metadata); } info(message, metadata) { - this._logWithStack("info" /* INFO */, message, metadata); + this._logWithStack(LOG_LEVEL.INFO, message, metadata); } debug(message, metadata) { - this._logWithStack("debug" /* DEBUG */, message, metadata); + this._logWithStack(LOG_LEVEL.DEBUG, message, metadata); } verbose(message, metadata) { - this._logWithStack("verbose" /* VERBOSE */, message, metadata); + this._logWithStack(LOG_LEVEL.VERBOSE, message, metadata); } - _logWithStack(type, message, metadata) { + _logWithStack(type, message, metaData) { this._log(type, message); - if (typeof metadata === "string") { - this._log(type, metadata); + if (typeof metaData === "string") { + this._log(type, metaData); return; } - if (metadata) { + if (metaData) { + const metadata = metaData; let stack = metadata?.error?.stack || metadata?.stack; if (!stack) { const stackTrace = new Error().stack?.split("\n"); @@ -51,11 +88,11 @@ var PrettyLogs = class { } if (typeof stack == "string") { const prettyStack = this._formatStackTrace(stack, 1); - const colorizedStack = this._colorizeText(prettyStack, "\x1B[2m" /* dim */); + const colorizedStack = this._colorizeText(prettyStack, COLORS.dim); this._log(type, colorizedStack); } else if (stack) { const prettyStack = this._formatStackTrace(stack.join("\n"), 1); - const colorizedStack = this._colorizeText(prettyStack, "\x1B[2m" /* dim */); + const colorizedStack = this._colorizeText(prettyStack, COLORS.dim); this._log(type, colorizedStack); } else { throw new Error("Stack is null"); @@ -66,7 +103,7 @@ var PrettyLogs = class { if (!color) { throw new Error(`Invalid color: ${color}`); } - return color.concat(text).concat("\x1B[0m" /* reset */); + return color.concat(text).concat(COLORS.reset); } _formatStackTrace(stack, linesToRemove = 0, prefix = "") { const lines = stack.split("\n"); @@ -85,25 +122,23 @@ var PrettyLogs = class { error: "\u26A0", info: "\u203A", debug: "\u203A\u203A", - verbose: "\u{1F4AC}", + verbose: "\u{1F4AC}" }; const symbol = defaultSymbols[type]; const messageFormatted = typeof message === "string" ? message : util.inspect(message, { showHidden: true, depth: null, breakLength: Infinity }); const lines = messageFormatted.split("\n"); - const logString = lines - .map((line, index) => { - const prefix = index === 0 ? ` ${symbol}` : ` ${" ".repeat(symbol.length)}`; - return `${prefix} ${line}`; - }) - .join("\n"); + const logString = lines.map((line, index) => { + const prefix = index === 0 ? ` ${symbol}` : ` ${" ".repeat(symbol.length)}`; + return `${prefix} ${line}`; + }).join("\n"); const fullLogString = logString; const colorMap = { - fatal: ["error", "\x1B[31m" /* fgRed */], - ok: ["log", "\x1B[32m" /* fgGreen */], - error: ["warn", "\x1B[33m" /* fgYellow */], - info: ["info", "\x1B[2m" /* dim */], - debug: ["debug", "\x1B[35m" /* fgMagenta */], - verbose: ["debug", "\x1B[2m" /* dim */], + fatal: ["error", COLORS.fgRed], + ok: ["log", COLORS.fgGreen], + error: ["warn", COLORS.fgYellow], + info: ["info", COLORS.dim], + debug: ["debug", COLORS.fgMagenta], + verbose: ["debug", COLORS.dim] }; const _console = console[colorMap[type][0]]; if (typeof _console === "function") { @@ -113,13 +148,7 @@ var PrettyLogs = class { } } }; -var LogLevel = /* @__PURE__ */ ((LogLevel2) => { - LogLevel2["FATAL"] = "fatal"; - LogLevel2["ERROR"] = "error"; - LogLevel2["INFO"] = "info"; - LogLevel2["VERBOSE"] = "verbose"; - LogLevel2["DEBUG"] = "debug"; - return LogLevel2; -})(LogLevel || {}); -export { LogLevel, PrettyLogs }; -//# sourceMappingURL=pretty-logs.js.map +export { + PrettyLogs +}; +//# sourceMappingURL=pretty-logs.js.map \ No newline at end of file diff --git a/dist/pretty-logs.js.map b/dist/pretty-logs.js.map index 6f81804..c72830c 100644 --- a/dist/pretty-logs.js.map +++ b/dist/pretty-logs.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/supabase/helpers/tables/pretty-logs.ts"],"sourcesContent":["import util from \"util\";\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-explicit-any */\ntype PrettyLogsWithOk = \"ok\" | LogLevel;\nexport class PrettyLogs {\n constructor() {\n this.ok = this.ok.bind(this);\n this.info = this.info.bind(this);\n this.error = this.error.bind(this);\n this.fatal = this.fatal.bind(this);\n this.debug = this.debug.bind(this);\n this.verbose = this.verbose.bind(this);\n }\n public fatal(message: string, metadata?: any) {\n this._logWithStack(LogLevel.FATAL, message, metadata);\n }\n\n public error(message: string, metadata?: any) {\n this._logWithStack(LogLevel.ERROR, message, metadata);\n }\n\n public ok(message: string, metadata?: any) {\n this._logWithStack(\"ok\", message, metadata);\n }\n\n public info(message: string, metadata?: any) {\n this._logWithStack(LogLevel.INFO, message, metadata);\n }\n\n public debug(message: string, metadata?: any) {\n this._logWithStack(LogLevel.DEBUG, message, metadata);\n }\n\n public verbose(message: string, metadata?: any) {\n this._logWithStack(LogLevel.VERBOSE, message, metadata);\n }\n\n private _logWithStack(type: \"ok\" | LogLevel, message: string, metadata?: Metadata | string) {\n this._log(type, message);\n if (typeof metadata === \"string\") {\n this._log(type, metadata);\n return;\n }\n if (metadata) {\n let stack = metadata?.error?.stack || metadata?.stack;\n if (!stack) {\n // generate and remove the top four lines of the stack trace\n const stackTrace = new Error().stack?.split(\"\\n\");\n if (stackTrace) {\n stackTrace.splice(0, 4);\n stack = stackTrace.filter((line) => line.includes(\".ts:\")).join(\"\\n\");\n }\n }\n const newMetadata = { ...metadata };\n delete newMetadata.message;\n delete newMetadata.name;\n delete newMetadata.stack;\n\n if (!this._isEmpty(newMetadata)) {\n this._log(type, newMetadata);\n }\n\n if (typeof stack == \"string\") {\n const prettyStack = this._formatStackTrace(stack, 1);\n const colorizedStack = this._colorizeText(prettyStack, Colors.dim);\n this._log(type, colorizedStack);\n } else if (stack) {\n const prettyStack = this._formatStackTrace((stack as unknown as string[]).join(\"\\n\"), 1);\n const colorizedStack = this._colorizeText(prettyStack, Colors.dim);\n this._log(type, colorizedStack);\n } else {\n throw new Error(\"Stack is null\");\n }\n }\n }\n\n private _colorizeText(text: string, color: Colors): string {\n if (!color) {\n throw new Error(`Invalid color: ${color}`);\n }\n return color.concat(text).concat(Colors.reset);\n }\n\n private _formatStackTrace(stack: string, linesToRemove = 0, prefix = \"\"): string {\n const lines = stack.split(\"\\n\");\n for (let i = 0; i < linesToRemove; i++) {\n lines.shift(); // Remove the top line\n }\n return lines\n .map((line) => `${prefix}${line.replace(/\\s*at\\s*/, \" ↳ \")}`) // Replace 'at' and prefix every line\n .join(\"\\n\");\n }\n\n private _isEmpty(obj: Record) {\n return !Reflect.ownKeys(obj).some((key) => typeof obj[String(key)] !== \"function\");\n }\n\n private _log(type: PrettyLogsWithOk, message: any) {\n const defaultSymbols: Record = {\n fatal: \"×\",\n ok: \"✓\",\n error: \"⚠\",\n info: \"›\",\n debug: \"››\",\n verbose: \"💬\",\n };\n\n const symbol = defaultSymbols[type];\n\n // Formatting the message\n const messageFormatted = typeof message === \"string\" ? message : util.inspect(message, { showHidden: true, depth: null, breakLength: Infinity });\n // const messageFormatted =\n // typeof message === \"string\" ? message : JSON.stringify(Logs.convertErrorsIntoObjects(message));\n\n // Constructing the full log string with the prefix symbol\n const lines = messageFormatted.split(\"\\n\");\n const logString = lines\n .map((line, index) => {\n // Add the symbol only to the first line and keep the indentation for the rest\n const prefix = index === 0 ? `\\t${symbol}` : `\\t${\" \".repeat(symbol.length)}`;\n return `${prefix} ${line}`;\n })\n .join(\"\\n\");\n\n const fullLogString = logString;\n\n const colorMap: Record = {\n fatal: [\"error\", Colors.fgRed],\n ok: [\"log\", Colors.fgGreen],\n error: [\"warn\", Colors.fgYellow],\n info: [\"info\", Colors.dim],\n debug: [\"debug\", Colors.fgMagenta],\n verbose: [\"debug\", Colors.dim],\n };\n\n const _console = console[colorMap[type][0] as keyof typeof console] as (...args: string[]) => void;\n if (typeof _console === \"function\") {\n _console(this._colorizeText(fullLogString, colorMap[type][1]));\n } else {\n throw new Error(fullLogString);\n }\n }\n}\ninterface Metadata {\n error?: { stack?: string };\n stack?: string;\n message?: string;\n name?: string;\n [key: string]: any;\n}\n\nenum Colors {\n reset = \"\\x1b[0m\",\n bright = \"\\x1b[1m\",\n dim = \"\\x1b[2m\",\n underscore = \"\\x1b[4m\",\n blink = \"\\x1b[5m\",\n reverse = \"\\x1b[7m\",\n hidden = \"\\x1b[8m\",\n\n fgBlack = \"\\x1b[30m\",\n fgRed = \"\\x1b[31m\",\n fgGreen = \"\\x1b[32m\",\n fgYellow = \"\\x1b[33m\",\n fgBlue = \"\\x1b[34m\",\n fgMagenta = \"\\x1b[35m\",\n fgCyan = \"\\x1b[36m\",\n fgWhite = \"\\x1b[37m\",\n\n bgBlack = \"\\x1b[40m\",\n bgRed = \"\\x1b[41m\",\n bgGreen = \"\\x1b[42m\",\n bgY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D,OAAO;AACL,YAAM,IAAI,MAAM,aAAa;AAAA,IAC/B;AAAA,EACF;AACF;AAoCO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,aAAU;AACV,EAAAA,UAAA,WAAQ;AALE,SAAAA;AAAA,GAAA;","names":["LogLevel"]} \ No newline at end of file +{"version":3,"sources":["../src/supabase/helpers/tables/pretty-logs.ts","../src/supabase/constants.ts"],"sourcesContent":["import util from \"util\";\nimport { Colors, Metadata, PrettyLogsWithOk } from \"../../types/logs\";\nimport { COLORS, LOG_LEVEL } from \"../../constants\";\n\nexport class PrettyLogs {\n constructor() {\n this.ok = this.ok.bind(this);\n this.info = this.info.bind(this);\n this.error = this.error.bind(this);\n this.fatal = this.fatal.bind(this);\n this.debug = this.debug.bind(this);\n this.verbose = this.verbose.bind(this);\n }\n public fatal(message: string, metadata?: Metadata | string | unknown) {\n this._logWithStack(LOG_LEVEL.FATAL, message, metadata);\n }\n\n public error(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.ERROR, message, metadata);\n }\n\n public ok(message: string, metadata?: Metadata | string) {\n this._logWithStack(\"ok\", message, metadata);\n }\n\n public info(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.INFO, message, metadata);\n }\n\n public debug(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.DEBUG, message, metadata);\n }\n\n public verbose(message: string, metadata?: Metadata | string) {\n this._logWithStack(LOG_LEVEL.VERBOSE, message, metadata);\n }\n\n private _logWithStack(type: PrettyLogsWithOk, message: string, metaData?: Metadata | string | unknown) {\n this._log(type, message);\n if (typeof metaData === \"string\") {\n this._log(type, metaData);\n return;\n }\n if (metaData) {\n const metadata = metaData as Metadata;\n let stack = metadata?.error?.stack || metadata?.stack;\n if (!stack) {\n // generate and remove the top four lines of the stack trace\n const stackTrace = new Error().stack?.split(\"\\n\");\n if (stackTrace) {\n stackTrace.splice(0, 4);\n stack = stackTrace.filter((line) => line.includes(\".ts:\")).join(\"\\n\");\n }\n }\n const newMetadata = { ...metadata };\n delete newMetadata.message;\n delete newMetadata.name;\n delete newMetadata.stack;\n\n if (!this._isEmpty(newMetadata)) {\n this._log(type, newMetadata);\n }\n\n if (typeof stack == \"string\") {\n const prettyStack = this._formatStackTrace(stack, 1);\n const colorizedStack = this._colorizeText(prettyStack, COLORS.dim);\n this._log(type, colorizedStack);\n } else if (stack) {\n const prettyStack = this._formatStackTrace((stack as unknown as string[]).join(\"\\n\"), 1);\n const colorizedStack = this._colorizeText(prettyStack, COLORS.dim);\n this._log(type, colorizedStack);\n } else {\n throw new Error(\"Stack is null\");\n }\n }\n }\n\n private _colorizeText(text: string, color: Colors): string {\n if (!color) {\n throw new Error(`Invalid color: ${color}`);\n }\n return color.concat(text).concat(COLORS.reset);\n }\n\n private _formatStackTrace(stack: string, linesToRemove = 0, prefix = \"\"): string {\n const lines = stack.split(\"\\n\");\n for (let i = 0; i < linesToRemove; i++) {\n lines.shift(); // Remove the top line\n }\n return lines\n .map((line) => `${prefix}${line.replace(/\\s*at\\s*/, \" ↳ \")}`) // Replace 'at' and prefix every line\n .join(\"\\n\");\n }\n\n private _isEmpty(obj: Record) {\n return !Reflect.ownKeys(obj).some((key) => typeof obj[String(key)] !== \"function\");\n }\n\n private _log(type: PrettyLogsWithOk, message: string | Record) {\n const defaultSymbols: Record = {\n fatal: \"×\",\n ok: \"✓\",\n error: \"⚠\",\n info: \"›\",\n debug: \"››\",\n verbose: \"💬\",\n };\n\n const symbol = defaultSymbols[type];\n\n // Formatting the message\n const messageFormatted = typeof message === \"string\" ? message : util.inspect(message, { showHidden: true, depth: null, breakLength: Infinity });\n // const messageFormatted =\n // typeof message === \"string\" ? message : JSON.stringify(Logs.convertErrorsIntoObjects(message));\n\n // Constructing the full log string with the prefix symbol\n const lines = messageFormatted.split(\"\\n\");\n const logString = lines\n .map((line, index) => {\n // Add the symbol only to the first line and keep the indentation for the rest\n const prefix = index === 0 ? `\\t${symbol}` : `\\t${\" \".repeat(symbol.length)}`;\n return `${prefix} ${line}`;\n })\n .join(\"\\n\");\n\n const fullLogString = logString;\n\n const colorMap: Record = {\n fatal: [\"error\", COLORS.fgRed],\n ok: [\"log\", COLORS.fgGreen],\n error: [\"warn\", COLORS.fgYellow],\n info: [\"info\", COLORS.dim],\n debug: [\"debug\", COLORS.fgMagenta],\n verbose: [\"debug\", COLORS.dim],\n };\n\n const _console = console[colorMap[type][0] as keyof typeof console] as (...args: string[]) => void;\n if (typeof _console === \"function\") {\n _console(this._colorizeText(fullLogString, colorMap[type][1]));\n } else {\n throw new Error(fullLogString);\n }\n }\n}\n","export const COLORS = {\n reset: \"\\x1b[0m\",\n bright: \"\\x1b[1m\",\n dim: \"\\x1b[2m\",\n underscore: \"\\x1b[4m\",\n blink: \"\\x1b[5m\",\n reverse: \"\\x1b[7m\",\n hidden: \"\\x1b[8m\",\n\n fgBlack: \"\\x1b[30m\",\n fgRed: \"\\x1b[31m\",\n fgGreen: \"\\x1b[32m\",\n fgYellow: \"\\x1b[33m\",\n fgBlue: \"\\x1b[34m\",\n fgMagenta: \"\\x1b[35m\",\n fgCyan: \"\\x1b[36m\",\n fgWhite: \"\\x1b[37m\",\n\n bgBlack: \"\\x1b[40m\",\n bgRed: \"\\x1b[41m\",\n bgGreen: \"\\x1b[42m\",\n bgYellow: \"\\x1b[43m\",\n bgBlue: \"\\x1b[44m\",\n bgMagenta: \"\\x1b[45m\",\n bgCyan: \"\\x1b[46m\",\n bgWhite: \"\\x1b[47m\",\n} as const;\n\nexport const LOG_LEVEL = {\n FATAL: \"fatal\",\n ERROR: \"error\",\n INFO: \"info\",\n VERBOSE: \"verbose\",\n DEBUG: \"debug\",\n} as const;\n"],"mappings":";AAAA,OAAO,UAAU;;;ACAV,IAAM,SAAS;AAAA,EACpB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA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