()
| 12 | * Hook to manage the logger instance. |
| 13 | */ |
| 14 | export const useLogger = () => { |
| 15 | const [logger, setLogger] = useState<Logger | null>(null); |
| 16 | |
| 17 | useEffect(() => { |
| 18 | const newLogger = new Logger(sessionId); |
| 19 | /** |
| 20 | * Start async initialization, no need to await. Using await slows down the |
| 21 | * time from launch to see the anus-cli prompt and it's better to not save |
| 22 | * messages than for the cli to hanging waiting for the logger to loading. |
| 23 | */ |
| 24 | newLogger |
| 25 | .initialize() |
| 26 | .then(() => { |
| 27 | setLogger(newLogger); |
| 28 | }) |
| 29 | .catch(() => {}); |
| 30 | }, []); |
| 31 | |
| 32 | return logger; |
| 33 | }; |
no test coverage detected