Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Metadata is Properly Passed to LogReturn in Logging Class #48

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const COLORS = {
} as const;

export const LOG_LEVEL = {
FATAL: "fatal",
ERROR: "error",
INFO: "info",
VERBOSE: "verbose",
DEBUG: "debug",
FATAL: 'fatal',
ERROR: 'error',
INFO: 'info',
VERBOSE: 'verbose',
DEBUG: 'debug',
} as const;
30 changes: 16 additions & 14 deletions src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,23 @@ export class Logs {
}

private _getNumericLevel(level: LogLevel) {
switch (level) {
case LOG_LEVEL.FATAL:
return 0;
case LOG_LEVEL.ERROR:
return 1;
case LOG_LEVEL.INFO:
return 2;
case LOG_LEVEL.VERBOSE:
return 4;
case LOG_LEVEL.DEBUG:
return 5;
default:
return -1;
}
switch (level) {
case LOG_LEVEL.FATAL:
return 0;
case LOG_LEVEL.ERROR:
return 1;
case LOG_LEVEL.INFO:
return 2;
case LOG_LEVEL.VERBOSE:
return 4;
case LOG_LEVEL.DEBUG:
return 5;
case LOG_LEVEL.TRACE: // New log level
return 6; // Assign a higher numeric value
default:
return -1;
}
}
static convertErrorsIntoObjects(obj: unknown): Metadata | unknown {
// this is a utility function to render native errors in the console, the database, and on GitHub.
if (obj instanceof Error) {
Expand Down
4 changes: 2 additions & 2 deletions src/pretty-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class PrettyLogs {
error: "⚠",
info: "›",
debug: "››",
verbose: "💬",
verbose: "💬"
};

const symbol = defaultSymbols[type];
Expand All @@ -127,7 +127,7 @@ export class PrettyLogs {
error: ["warn", COLORS.fgYellow],
info: ["info", COLORS.dim],
debug: ["debug", COLORS.fgMagenta],
verbose: ["debug", COLORS.dim],
verbose: ["verbose", COLORS.dim]
};

const _console = console[colorMap[type][0] as keyof typeof console] as (...args: string[]) => void;
Expand Down
Loading