@ubiquity-os/ubiquity-os-logger
Version:
Ubiquity logging module with Supabase support.
101 lines (95 loc) • 3.38 kB
text/typescript
declare const COLORS: {
readonly reset: "\u001B[0m";
readonly bright: "\u001B[1m";
readonly dim: "\u001B[2m";
readonly underscore: "\u001B[4m";
readonly blink: "\u001B[5m";
readonly reverse: "\u001B[7m";
readonly hidden: "\u001B[8m";
readonly fgBlack: "\u001B[30m";
readonly fgRed: "\u001B[31m";
readonly fgGreen: "\u001B[32m";
readonly fgYellow: "\u001B[33m";
readonly fgBlue: "\u001B[34m";
readonly fgMagenta: "\u001B[35m";
readonly fgCyan: "\u001B[36m";
readonly fgWhite: "\u001B[37m";
readonly bgBlack: "\u001B[40m";
readonly bgRed: "\u001B[41m";
readonly bgGreen: "\u001B[42m";
readonly bgYellow: "\u001B[43m";
readonly bgBlue: "\u001B[44m";
readonly bgMagenta: "\u001B[45m";
readonly bgCyan: "\u001B[46m";
readonly bgWhite: "\u001B[47m";
};
declare const LOG_LEVEL: {
readonly FATAL: "fatal";
readonly ERROR: "error";
readonly WARN: "warn";
readonly INFO: "info";
readonly VERBOSE: "verbose";
readonly DEBUG: "debug";
};
type LogMessage = {
raw: string;
diff: string;
level: LogLevel;
type: LogLevelWithOk;
};
type Colors = (typeof COLORS)[keyof typeof COLORS];
type LogLevel = (typeof LOG_LEVEL)[keyof typeof LOG_LEVEL];
type LogLevelWithOk = "ok" | LogLevel;
interface MetadataInterface {
error: Error | {
stack: string;
};
stack: string | string[] | null;
message: string;
name: string;
[key: string]: unknown;
}
type Metadata = Partial<MetadataInterface>;
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;
warn(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;
}
declare class Logs {
private _maxLevel;
static console: PrettyLogs;
private _log;
private _addDiagnosticInformation;
ok(log: string, metadata?: Metadata): LogReturn;
info(log: string, metadata?: Metadata): LogReturn;
warn(log: string, metadata?: Metadata): LogReturn;
error(log: string, metadata?: Metadata): LogReturn;
debug(log: string, metadata?: Metadata): LogReturn;
fatal(log: string, metadata?: Metadata): LogReturn;
verbose(log: string, metadata?: Metadata): LogReturn;
constructor(logLevel: LogLevel);
private _diffColorCommentMessage;
private _getNumericLevel;
static convertErrorsIntoObjects(obj: unknown): Metadata | unknown;
}
declare function cleanLogString(logString: string): string;
declare function cleanSpyLogs(spy: jest.SpiedFunction<{
(...data: string[]): void;
(message?: string, ...optionalParams: string[]): void;
}>): string[];
export { COLORS, type Colors, LOG_LEVEL, type LogLevel, type LogLevelWithOk, LogReturn, Logs, type Metadata, PrettyLogs, cleanLogString, cleanSpyLogs };