1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Close log files on unmount

Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com>
This commit is contained in:
Sami Tiilikainen 2022-12-21 14:08:10 +02:00
parent 528e18e99e
commit 0c83cfb0e8
2 changed files with 29 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import { Router } from "react-router";
import historyInjectable from "./navigation/history.injectable"; import historyInjectable from "./navigation/history.injectable";
import assert from "assert"; import assert from "assert";
import startFrameInjectable from "./start-frame/start-frame.injectable"; import startFrameInjectable from "./start-frame/start-frame.injectable";
import closeRendererLogFileInjectable from "./logger/close-renderer-log-file.injectable";
export async function bootstrap(di: DiContainer) { export async function bootstrap(di: DiContainer) {
const startFrame = di.inject(startFrameInjectable); const startFrame = di.inject(startFrameInjectable);
@ -54,7 +55,15 @@ export async function bootstrap(di: DiContainer) {
} }
try { try {
await initializeApp(() => unmountComponentAtNode(rootElem)); const unmount = () => {
const closeLogFile = di.inject(closeRendererLogFileInjectable);
closeLogFile();
unmountComponentAtNode(rootElem);
};
await initializeApp(unmount);
} catch (error) { } catch (error) {
console.error(`[BOOTSTRAP]: view initialization error: ${error}`, { console.error(`[BOOTSTRAP]: view initialization error: ${error}`, {
origin: location.href, origin: location.href,

View File

@ -0,0 +1,19 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import rendererFileLoggerTransportInjectable from "./file-transport.injectable";
const closeRendererLogFileInjectable = getInjectable({
id: "close-renderer-log-file",
instantiate: (di) => {
const fileLoggingTransport = di.inject(rendererFileLoggerTransportInjectable);
return () => {
fileLoggingTransport.close?.();
};
},
});
export default closeRendererLogFileInjectable;