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:
parent
528e18e99e
commit
0c83cfb0e8
@ -19,6 +19,7 @@ import { Router } from "react-router";
|
||||
import historyInjectable from "./navigation/history.injectable";
|
||||
import assert from "assert";
|
||||
import startFrameInjectable from "./start-frame/start-frame.injectable";
|
||||
import closeRendererLogFileInjectable from "./logger/close-renderer-log-file.injectable";
|
||||
|
||||
export async function bootstrap(di: DiContainer) {
|
||||
const startFrame = di.inject(startFrameInjectable);
|
||||
@ -54,7 +55,15 @@ export async function bootstrap(di: DiContainer) {
|
||||
}
|
||||
|
||||
try {
|
||||
await initializeApp(() => unmountComponentAtNode(rootElem));
|
||||
const unmount = () => {
|
||||
const closeLogFile = di.inject(closeRendererLogFileInjectable);
|
||||
|
||||
closeLogFile();
|
||||
|
||||
unmountComponentAtNode(rootElem);
|
||||
};
|
||||
|
||||
await initializeApp(unmount);
|
||||
} catch (error) {
|
||||
console.error(`[BOOTSTRAP]: view initialization error: ${error}`, {
|
||||
origin: location.href,
|
||||
|
||||
@ -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;
|
||||
Loading…
Reference in New Issue
Block a user