(
options: CreateMockLoggerOptions = {},
)
| 35 | } |
| 36 | |
| 37 | export function createMockLogger( |
| 38 | options: CreateMockLoggerOptions = {}, |
| 39 | ): MockLogger { |
| 40 | const { customImplementations = {} } = options |
| 41 | |
| 42 | const createLogMethod = (level: LogLevel): MockLogMethod => { |
| 43 | const customImpl = customImplementations[level] |
| 44 | if (customImpl) { |
| 45 | return mock(customImpl) |
| 46 | } |
| 47 | return mock(() => {}) |
| 48 | } |
| 49 | |
| 50 | const mockLogger: MockLogger = { |
| 51 | trace: createLogMethod('trace'), |
| 52 | debug: createLogMethod('debug'), |
| 53 | info: createLogMethod('info'), |
| 54 | warn: createLogMethod('warn'), |
| 55 | error: createLogMethod('error'), |
| 56 | fatal: createLogMethod('fatal'), |
| 57 | child: mock(() => createMockLogger(options)), |
| 58 | } |
| 59 | |
| 60 | return mockLogger |
| 61 | } |
| 62 | |
| 63 | export interface MockLoggerWithCapture { |
| 64 | logger: MockLogger |
no test coverage detected