Skip to content

Commit

Permalink
Revert "Renderer file logging transport (#6795)"
Browse files Browse the repository at this point in the history
Renderer file logging still caused UI freezing (at least on apple silicon macs) when cluster frame was open and main frame was reloaded.

See #544

This reverts commit ac2d0e4.

Signed-off-by: Sami Tiilikainen <97873007+samitiilikainen@users.noreply.github.com>
  • Loading branch information
samitiilikainen committed Feb 28, 2023
1 parent 1b808cf commit fec4415
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 105 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/common/logger.injectable.ts
Expand Up @@ -3,13 +3,20 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { createLogger, format } from "winston";
import type { Logger } from "./logger";
import winstonLoggerInjectable from "./winston-logger.injectable";
import { loggerTransportInjectionToken } from "./logger/transports";

const loggerInjectable = getInjectable({
id: "logger",
instantiate: (di): Logger => {
const baseLogger = di.inject(winstonLoggerInjectable);
const baseLogger = createLogger({
format: format.combine(
format.splat(),
format.simple(),
),
transports: di.injectMany(loggerTransportInjectionToken),
});

return {
debug: (message, ...data) => baseLogger.debug(message, ...data),
Expand Down
20 changes: 0 additions & 20 deletions packages/core/src/common/winston-logger.injectable.ts

This file was deleted.

4 changes: 1 addition & 3 deletions packages/core/src/renderer/bootstrap.tsx
Expand Up @@ -46,9 +46,7 @@ export async function bootstrap(di: DiContainer) {
}

try {
await initializeApp(() => {
unmountComponentAtNode(rootElem);
});
await initializeApp(() => unmountComponentAtNode(rootElem));
} catch (error) {
console.error(`[BOOTSTRAP]: view initialization error: ${error}`, {
origin: location.href,
Expand Down
Expand Up @@ -12,7 +12,6 @@ import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.
import loadExtensionsInjectable from "../../load-extensions.injectable";
import loggerInjectable from "../../../../common/logger.injectable";
import showErrorNotificationInjectable from "../../../components/notifications/show-error-notification.injectable";
import closeRendererLogFileInjectable from "../../../logger/close-renderer-log-file.injectable";

const initClusterFrameInjectable = getInjectable({
id: "init-cluster-frame",
Expand All @@ -30,7 +29,6 @@ const initClusterFrameInjectable = getInjectable({
emitAppEvent: di.inject(emitAppEventInjectable),
logger: di.inject(loggerInjectable),
showErrorNotification: di.inject(showErrorNotificationInjectable),
closeFileLogging: di.inject(closeRendererLogFileInjectable),
});
},
});
Expand Down
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { once } from "lodash";
import type { Cluster } from "../../../../common/cluster/cluster";
import type { CatalogEntityRegistry } from "../../../api/catalog/entity/registry";
import type { ShowNotification } from "../../../components/notifications";
Expand All @@ -19,7 +18,6 @@ interface Dependencies {
emitAppEvent: EmitAppEvent;
logger: Logger;
showErrorNotification: ShowNotification;
closeFileLogging: () => void;
}

const logPrefix = "[CLUSTER-FRAME]:";
Expand All @@ -32,7 +30,6 @@ export const initClusterFrame = ({
emitAppEvent,
logger,
showErrorNotification,
closeFileLogging,
}: Dependencies) =>
async (unmountRoot: () => void) => {
// TODO: Make catalogEntityRegistry already initialized when passed as dependency
Expand Down Expand Up @@ -76,14 +73,11 @@ export const initClusterFrame = ({
});
});

const onCloseFrame = once(() => {
window.onbeforeunload = () => {
logger.info(
`${logPrefix} Unload dashboard, clusterId=${(hostedCluster.id)}, frameId=${frameRoutingId}`,
);
closeFileLogging();
unmountRoot();
});

window.addEventListener("beforeunload", onCloseFrame);
window.addEventListener("pagehide", onCloseFrame);
unmountRoot();
};
};
Expand Up @@ -13,7 +13,6 @@ import loggerInjectable from "../../../common/logger.injectable";
import { delay } from "../../../common/utils";
import { broadcastMessage } from "../../../common/ipc";
import { bundledExtensionsLoaded } from "../../../common/ipc/extension-handling";
import closeRendererLogFileInjectable from "../../logger/close-renderer-log-file.injectable";

const initRootFrameInjectable = getInjectable({
id: "init-root-frame",
Expand All @@ -25,7 +24,6 @@ const initRootFrameInjectable = getInjectable({
const lensProtocolRouterRenderer = di.inject(lensProtocolRouterRendererInjectable);
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
const logger = di.inject(loggerInjectable);
const closeRendererLogFile = di.inject(closeRendererLogFileInjectable);

return async (unmountRoot: () => void) => {
catalogEntityRegistry.init();
Expand Down Expand Up @@ -61,7 +59,7 @@ const initRootFrameInjectable = getInjectable({

window.addEventListener("beforeunload", () => {
logger.info("[ROOT-FRAME]: Unload app");
closeRendererLogFile();

unmountRoot();
});
};
Expand Down

This file was deleted.

44 changes: 0 additions & 44 deletions packages/core/src/renderer/logger/file-transport.injectable.ts

This file was deleted.

0 comments on commit fec4415

Please sign in to comment.