| 23 | } |
| 24 | |
| 25 | export class Logger { |
| 26 | protected config: LoggerConfig; |
| 27 | |
| 28 | constructor({ context = 'sequelize', ...rest }: Partial<LoggerConfig> = {}) { |
| 29 | this.config = { |
| 30 | context, |
| 31 | ...rest |
| 32 | }; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Logs a warning in the logger's context. |
| 37 | * |
| 38 | * @param message The message of the warning. |
| 39 | */ |
| 40 | warn(message: string): void { |
| 41 | console.warn(`(${this.config.context}) Warning: ${message}`); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Uses node's util.inspect to stringify a value. |
| 46 | * |
| 47 | * @param value The value which should be inspected. |
| 48 | * @returns The string of the inspected value. |
| 49 | */ |
| 50 | inspect(value: unknown): string { |
| 51 | return util.inspect(value, { |
| 52 | showHidden: false, |
| 53 | depth: 1 |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Gets a debugger for a context. |
| 59 | * |
| 60 | * @param name The name of the context. |
| 61 | * @returns A debugger interace which can be used to debug. |
| 62 | */ |
| 63 | debugContext(name: string): nodeDebug.Debugger { |
| 64 | return nodeDebug(`${this.config.context}:${name}`); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | export const logger = new Logger(); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…