(format: LogFormat)
| 39 | * Creates a formatter for the specified log format. |
| 40 | */ |
| 41 | export function createLogFormatter(format: LogFormat): ConsoleFormatter { |
| 42 | switch (format) { |
| 43 | case 'json': |
| 44 | return new JsonFormatter() |
| 45 | case 'text': |
| 46 | return new TextFormatter() |
| 47 | default: |
| 48 | throw new Error(`Invalid log format: ${format satisfies never}`) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Formatter that outputs log events as JSON strings. |
no outgoing calls
no test coverage detected