๐Ÿ“ฆ Kong / insomnia

๐Ÿ“„ logger.ts ยท 23 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23import type { logType } from 'consola';
import consola, { BasicReporter, FancyReporter, LogLevel } from 'consola';

type LogsByType = Partial<Record<logType, string[]>>;

type ModifiedConsola = ReturnType<typeof consola.create> & { __getLogs: () => LogsByType };

const consolaLogger = consola.create({
  reporters: [
    new FancyReporter({
      formatOptions: {
        // @ts-expect-error something is wrong here, ultimately these types come from https://nodejs.org/api/util.html#util_util_inspect_object_options and `date` doesn't appear to be one of the options.
        date: false,
      },
    }),
  ],
});

(consolaLogger as ModifiedConsola).__getLogs = () => ({});

export const logger = consolaLogger as ModifiedConsola;
export { LogLevel, BasicReporter };