()
| 10 | * @throws {Error} if no logger is found in the context or if the value is not a {@link Logger} |
| 11 | */ |
| 12 | export function getActiveLogger(): Logger { |
| 13 | const logger = context.active().getValue(LOG_CONTEXT) |
| 14 | |
| 15 | if (!logger) { |
| 16 | throw new Error('No active logger found') |
| 17 | } |
| 18 | |
| 19 | if (logger instanceof Logger) { |
| 20 | return logger |
| 21 | } |
| 22 | |
| 23 | throw new Error('Active logger is not an instance of Logger') |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Runs a function with a new OpenTelemetry context containing the provided logger. |
no test coverage detected