output log messages with correct level
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user