diff --git a/dist/logs.js.map b/dist/logs.js.map deleted file mode 100644 index 57ab4d3..0000000 --- a/dist/logs.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/commit-hash.ts","../src/supabase/helpers/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,EAE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.d.ts new file mode 100644 index 0000000..2939aa7 --- /dev/null +++ b/dist/pretty-logs.d.ts @@ -0,0 +1,23 @@ +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 }; diff --git a/dist/pretty-logs.js b/dist/pretty-logs.js new file mode 100644 index 0000000..fbdc3a5 --- /dev/null +++ b/dist/pretty-logs.js @@ -0,0 +1,126 @@ +// src/supabase/helpers/pretty-logs.ts +import util from "util"; +var PrettyLogs = class { + constructor() { + this.ok = this.ok.bind(this); + this.info = this.info.bind(this); + this.error = this.error.bind(this); + this.fatal = this.fatal.bind(this); + this.debug = this.debug.bind(this); + this.verbose = this.verbose.bind(this); + } + fatal(message, metadata) { + this._logWithStack("fatal" /* FATAL */, message, metadata); + } + error(message, metadata) { + this._logWithStack("error" /* ERROR */, message, metadata); + } + ok(message, metadata) { + this._logWithStack("ok", message, metadata); + } + info(message, metadata) { + this._logWithStack("info" /* INFO */, message, metadata); + } + debug(message, metadata) { + this._logWithStack("debug" /* DEBUG */, message, metadata); + } + verbose(message, metadata) { + this._logWithStack("verbose" /* VERBOSE */, message, metadata); + } + _logWithStack(type, message, metadata) { + this._log(type, message); + if (typeof metadata === "string") { + this._log(type, metadata); + return; + } + if (metadata) { + let stack = metadata?.error?.stack || metadata?.stack; + if (!stack) { + const stackTrace = new Error().stack?.split("\n"); + if (stackTrace) { + stackTrace.splice(0, 4); + stack = stackTrace.filter((line) => line.includes(".ts:")).join("\n"); + } + } + const newMetadata = { ...metadata }; + delete newMetadata.message; + delete newMetadata.name; + delete newMetadata.stack; + if (!this._isEmpty(newMetadata)) { + this._log(type, newMetadata); + } + if (typeof stack == "string") { + const prettyStack = this._formatStackTrace(stack, 1); + const colorizedStack = this._colorizeText(prettyStack, "\x1B[2m" /* dim */); + this._log(type, colorizedStack); + } else if (stack) { + const prettyStack = this._formatStackTrace(stack.join("\n"), 1); + const colorizedStack = this._colorizeText(prettyStack, "\x1B[2m" /* dim */); + this._log(type, colorizedStack); + } else { + throw new Error("Stack is null"); + } + } + } + _colorizeText(text, color) { + if (!color) { + throw new Error(`Invalid color: ${color}`); + } + return color.concat(text).concat("\x1B[0m" /* reset */); + } + _formatStackTrace(stack, linesToRemove = 0, prefix = "") { + const lines = stack.split("\n"); + for (let i = 0; i < linesToRemove; i++) { + lines.shift(); + } + return lines.map((line) => `${prefix}${line.replace(/\s*at\s*/, " \u21B3 ")}`).join("\n"); + } + _isEmpty(obj) { + return !Reflect.ownKeys(obj).some((key) => typeof obj[String(key)] !== "function"); + } + _log(type, message) { + const defaultSymbols = { + fatal: "\xD7", + ok: "\u2713", + error: "\u26A0", + info: "\u203A", + debug: "\u203A\u203A", + 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 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 */] + }; + const _console = console[colorMap[type][0]]; + if (typeof _console === "function") { + _console(this._colorizeText(fullLogString, colorMap[type][1])); + } else { + throw new Error(fullLogString); + } + } +}; +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 \ No newline at end of file diff --git a/dist/pretty-logs.js.map b/dist/pretty-logs.js.map new file mode 100644 index 0000000..747a322 --- /dev/null +++ b/dist/pretty-logs.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/supabase/helpers/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 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"],"mappings":";AAAA,OAAO,UAAU;AAIV,IAAM,aAAN,MAAiB;AAAA,EACtB,cAAc;AACZ,SAAK,KAAK,KAAK,GAAG,KAAK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logs.d.ts rename to dist/tables/logs.d.ts index 023d71c..49fb93c 100644 --- a/dist/logs.d.ts +++ b/dist/tables/logs.d.ts @@ -1,27 +1,6 @@ import { SupabaseClient } from "@supabase/supabase-js"; import { Context } from "probot"; - -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", -} +import { LogLevel, PrettyLogs } from "../pretty-logs.js"; declare class LogReturn { logMessage: LogMessage; diff --git a/dist/logs.js b/dist/tables/logs.js similarity index 100% rename from dist/logs.js rename to dist/tables/logs.js diff --git a/dist/tables/logs.js.map b/dist/tables/logs.js.map new file mode 100644 index 0000000..07559c5 --- /dev/null +++ b/dist/tables/logs.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/commit-hash.ts","../../src/supabase/helpers/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,EAA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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 diff --git a/package.json b/package.json index daf982d..ade76f2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "type": "module", "tsup": { "entry": [ - "src/supabase/helpers/tables/logs.ts" + "src/supabase/helpers/tables/logs.ts", + "src/supabase/helpers/pretty-logs.ts" ], "splitting": false, "sourcemap": true, @@ -23,6 +24,9 @@ "*": { ".": [ "./dist/logs.d.ts" + ], + "pretty-logs": [ + "./dist/pretty-logs.d.ts" ] } }, @@ -30,6 +34,10 @@ ".": { "types": "./dist/logs.d.ts", "default": "./dist/logs.js" + }, + "./pretty-logs": { + "types": "./dist/pretty-logs.d.ts", + "default": "./dist/pretty-logs.js" } }, "scripts": {