1
0

output log messages with correct level

This commit is contained in:
Hazelnoot
2025-06-06 13:36:33 -04:00
parent 00c0bdbc94
commit d0ae76214c
2 changed files with 19 additions and 6 deletions
+9 -1
View File
@@ -23,6 +23,14 @@ export type DataElement = DataObject | Error | string | null;
// https://stackoverflow.com/questions/61148466/typescript-type-that-matches-any-object-but-not-arrays
export type DataObject = Record<string, unknown> | (object & { length?: never; });
const levelFuncs = {
error: 'error',
warning: 'warn',
success: 'info',
info: 'log',
debug: 'debug',
} as const satisfies Record<Level, keyof typeof console>;
// eslint-disable-next-line import/no-default-export
export default class Logger {
private context: Context;
@@ -86,7 +94,7 @@ export default class Logger {
} else if (data != null) {
args.push(data);
}
console.log(...args);
console[levelFuncs[level]](...args);
}
@bindThis