Merge pull request #3924 from element-hq/valere/devx/livekit_logs
dev-tool: Add option to enable extended livekit logs
This commit is contained in:
@@ -23,12 +23,17 @@ import {
|
|||||||
createRoutesFromChildren,
|
createRoutesFromChildren,
|
||||||
matchRoutes,
|
matchRoutes,
|
||||||
} from "react-router-dom";
|
} from "react-router-dom";
|
||||||
|
import {
|
||||||
|
setLogExtension as setLKLogExtension,
|
||||||
|
setLogLevel as setLKLogLevel,
|
||||||
|
} from "livekit-client";
|
||||||
|
|
||||||
import { getUrlParams } from "./UrlParams";
|
import { getUrlParams } from "./UrlParams";
|
||||||
import { Config } from "./config/Config";
|
import { Config } from "./config/Config";
|
||||||
import { platform } from "./Platform";
|
import { platform } from "./Platform";
|
||||||
import { isFailure } from "./utils/fetch";
|
import { isFailure } from "./utils/fetch";
|
||||||
import { initializeWidget } from "./widget";
|
import { initializeWidget } from "./widget";
|
||||||
|
import { enableExtendedLivekitLogs } from "./settings/settings.ts";
|
||||||
|
|
||||||
// This generates a map of locale names to their URL (based on import.meta.url), which looks like this:
|
// This generates a map of locale names to their URL (based on import.meta.url), which looks like this:
|
||||||
// {
|
// {
|
||||||
@@ -189,6 +194,18 @@ export class Initializer {
|
|||||||
|
|
||||||
// Add the platform to the DOM, so CSS can query it
|
// Add the platform to the DOM, so CSS can query it
|
||||||
document.body.setAttribute("data-platform", platform);
|
document.body.setAttribute("data-platform", platform);
|
||||||
|
|
||||||
|
// livekit logging configuration
|
||||||
|
setLKLogExtension((level, msg, context) => {
|
||||||
|
// we pass a synthetic logger name of "livekit" to the rageshake to make it easier to read
|
||||||
|
global.mx_rage_logger.log(level, "livekit", msg, context);
|
||||||
|
});
|
||||||
|
|
||||||
|
enableExtendedLivekitLogs.value$.subscribe((enabled) => {
|
||||||
|
setLKLogLevel(enabled ? "trace" : "info");
|
||||||
|
});
|
||||||
|
|
||||||
|
window.setLKLogLevel = setLKLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static init(): Promise<void> | null {
|
public static init(): Promise<void> | null {
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ import { StrictMode } from "react";
|
|||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import {
|
|
||||||
setLogExtension as setLKLogExtension,
|
|
||||||
setLogLevel as setLKLogLevel,
|
|
||||||
} from "livekit-client";
|
|
||||||
|
|
||||||
import { App } from "./App";
|
import { App } from "./App";
|
||||||
import { init as initRageshake } from "./settings/rageshake";
|
import { init as initRageshake } from "./settings/rageshake";
|
||||||
@@ -26,16 +22,9 @@ import { Initializer } from "./initializer";
|
|||||||
import { AppViewModel } from "./state/AppViewModel";
|
import { AppViewModel } from "./state/AppViewModel";
|
||||||
import { globalScope } from "./state/ObservableScope";
|
import { globalScope } from "./state/ObservableScope";
|
||||||
|
|
||||||
window.setLKLogLevel = setLKLogLevel;
|
|
||||||
|
|
||||||
initRageshake().catch((e) => {
|
initRageshake().catch((e) => {
|
||||||
logger.error("Failed to initialize rageshake", e);
|
logger.error("Failed to initialize rageshake", e);
|
||||||
});
|
});
|
||||||
setLKLogLevel("info");
|
|
||||||
setLKLogExtension((level, msg, context) => {
|
|
||||||
// we pass a synthetic logger name of "livekit" to the rageshake to make it easier to read
|
|
||||||
global.mx_rage_logger.log(level, "livekit", msg, context);
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.info(`Element Call ${import.meta.env.VITE_APP_VERSION || "dev"}`);
|
logger.info(`Element Call ${import.meta.env.VITE_APP_VERSION || "dev"}`);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ import type { MatrixClient } from "matrix-js-sdk";
|
|||||||
import type { Room as LivekitRoom } from "livekit-client";
|
import type { Room as LivekitRoom } from "livekit-client";
|
||||||
import { DeveloperSettingsTab } from "./DeveloperSettingsTab";
|
import { DeveloperSettingsTab } from "./DeveloperSettingsTab";
|
||||||
import { getSFUConfigWithOpenID } from "../livekit/openIDSFU";
|
import { getSFUConfigWithOpenID } from "../livekit/openIDSFU";
|
||||||
import { customLivekitUrl as customLivekitUrlSetting } from "./settings";
|
import {
|
||||||
|
customLivekitUrl as customLivekitUrlSetting,
|
||||||
|
enableExtendedLivekitLogs as enableExtendedLivekitLogsSetting,
|
||||||
|
} from "./settings";
|
||||||
|
|
||||||
// Mock url params hook to avoid environment-dependent snapshot churn.
|
// Mock url params hook to avoid environment-dependent snapshot churn.
|
||||||
vi.mock("../UrlParams", () => ({
|
vi.mock("../UrlParams", () => ({
|
||||||
useUrlParams: (): { mocked: boolean; answer: number } => ({
|
useUrlParams: (): { mocked: boolean; answer: number } => ({
|
||||||
@@ -248,4 +252,63 @@ describe("DeveloperSettingsTab", () => {
|
|||||||
expect(customLivekitUrlSetting.getValue()).toBe(null);
|
expect(customLivekitUrlSetting.getValue()).toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add this test inside the describe("DeveloperSettingsTab", () => { block,
|
||||||
|
// after the custom livekit url tests:
|
||||||
|
|
||||||
|
describe("enable extended livekit logs", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
enableExtendedLivekitLogsSetting.setValue(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("toggles extended livekit logs setting", async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
const client = createMockMatrixClient();
|
||||||
|
|
||||||
|
render(
|
||||||
|
<TooltipProvider>
|
||||||
|
<DeveloperSettingsTab
|
||||||
|
client={client}
|
||||||
|
env={{} as unknown as ImportMetaEnv}
|
||||||
|
/>
|
||||||
|
</TooltipProvider>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const checkbox = screen.getByLabelText("Enable extended livekit logs");
|
||||||
|
|
||||||
|
// Initial state should be unchecked (default false)
|
||||||
|
expect(checkbox).not.toBeChecked();
|
||||||
|
expect(enableExtendedLivekitLogsSetting.getValue()).toBe(false);
|
||||||
|
|
||||||
|
// Click to enable
|
||||||
|
await user.click(checkbox);
|
||||||
|
expect(checkbox).toBeChecked();
|
||||||
|
expect(enableExtendedLivekitLogsSetting.getValue()).toBe(true);
|
||||||
|
|
||||||
|
// Click to disable
|
||||||
|
await user.click(checkbox);
|
||||||
|
expect(checkbox).not.toBeChecked();
|
||||||
|
expect(enableExtendedLivekitLogsSetting.getValue()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Use the current setting value on render", () => {
|
||||||
|
const client = createMockMatrixClient();
|
||||||
|
|
||||||
|
// Set the value to true before rendering
|
||||||
|
enableExtendedLivekitLogsSetting.setValue(true);
|
||||||
|
|
||||||
|
render(
|
||||||
|
<TooltipProvider>
|
||||||
|
<DeveloperSettingsTab
|
||||||
|
client={client}
|
||||||
|
env={{} as unknown as ImportMetaEnv}
|
||||||
|
/>
|
||||||
|
</TooltipProvider>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const checkbox = screen.getByLabelText("Enable extended livekit logs");
|
||||||
|
expect(checkbox).toBeChecked();
|
||||||
|
expect(enableExtendedLivekitLogsSetting.getValue()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import {
|
|||||||
matrixRTCMode as matrixRTCModeSetting,
|
matrixRTCMode as matrixRTCModeSetting,
|
||||||
customLivekitUrl as customLivekitUrlSetting,
|
customLivekitUrl as customLivekitUrlSetting,
|
||||||
MatrixRTCMode,
|
MatrixRTCMode,
|
||||||
|
enableExtendedLivekitLogs as enableExtendedLivekitLogsSetting,
|
||||||
} from "./settings";
|
} from "./settings";
|
||||||
import styles from "./DeveloperSettingsTab.module.css";
|
import styles from "./DeveloperSettingsTab.module.css";
|
||||||
import { useUrlParams } from "../UrlParams";
|
import { useUrlParams } from "../UrlParams";
|
||||||
@@ -101,6 +102,10 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
|||||||
alwaysShowIphoneEarpieceSetting,
|
alwaysShowIphoneEarpieceSetting,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [enableExtendedLivekitLogs, setEnableExtendedLivekitLogs] = useSetting(
|
||||||
|
enableExtendedLivekitLogsSetting,
|
||||||
|
);
|
||||||
|
|
||||||
const [customLivekitUrlUpdateError, setCustomLivekitUrlUpdateError] =
|
const [customLivekitUrlUpdateError, setCustomLivekitUrlUpdateError] =
|
||||||
useState<string | null>(null);
|
useState<string | null>(null);
|
||||||
const [customLivekitUrl, setCustomLivekitUrl] = useSetting(
|
const [customLivekitUrl, setCustomLivekitUrl] = useSetting(
|
||||||
@@ -225,7 +230,21 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
|||||||
},
|
},
|
||||||
[setAlwaysShowIphoneEarpiece],
|
[setAlwaysShowIphoneEarpiece],
|
||||||
)}
|
)}
|
||||||
/>{" "}
|
/>
|
||||||
|
</FieldRow>
|
||||||
|
<FieldRow>
|
||||||
|
<InputField
|
||||||
|
id="enableLivekitExtendedLogs"
|
||||||
|
type="checkbox"
|
||||||
|
label="Enable extended livekit logs"
|
||||||
|
checked={enableExtendedLivekitLogs}
|
||||||
|
onChange={useCallback(
|
||||||
|
(event: ChangeEvent<HTMLInputElement>): void => {
|
||||||
|
setEnableExtendedLivekitLogs(event.target.checked);
|
||||||
|
},
|
||||||
|
[setEnableExtendedLivekitLogs],
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
<EditInPlace
|
<EditInPlace
|
||||||
onSubmit={(e) => e.preventDefault()}
|
onSubmit={(e) => e.preventDefault()}
|
||||||
|
|||||||
@@ -185,7 +185,43 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
Show iPhone earpiece option on all platforms
|
Show iPhone earpiece option on all platforms
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="fieldRow"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="field checkboxField"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-describedby="_r_6_"
|
||||||
|
id="enableLivekitExtendedLogs"
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
for="enableLivekitExtendedLogs"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="checkbox"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
fill="none"
|
||||||
|
height="24"
|
||||||
|
stroke="#000"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="24"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="m20 6-11 11-5-5"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
Enable extended livekit logs
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form
|
||||||
class="_root_19upo_16"
|
class="_root_19upo_16"
|
||||||
@@ -195,7 +231,7 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
class="_label_19upo_59"
|
class="_label_19upo_59"
|
||||||
for="radix-_r_6_"
|
for="radix-_r_7_"
|
||||||
>
|
>
|
||||||
Custom Livekit-url
|
Custom Livekit-url
|
||||||
</label>
|
</label>
|
||||||
@@ -203,9 +239,9 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
class="_controls_17lij_8"
|
class="_controls_17lij_8"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
aria-describedby="radix-_r_7_"
|
aria-describedby="radix-_r_8_"
|
||||||
class="_control_d83jn_10"
|
class="_control_d83jn_10"
|
||||||
id="radix-_r_6_"
|
id="radix-_r_7_"
|
||||||
name="input"
|
name="input"
|
||||||
title=""
|
title=""
|
||||||
value=""
|
value=""
|
||||||
@@ -213,7 +249,7 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<span
|
<span
|
||||||
class="_message_19upo_85 _help-message_19upo_91"
|
class="_message_19upo_85 _help-message_19upo_91"
|
||||||
id="radix-_r_7_"
|
id="radix-_r_8_"
|
||||||
>
|
>
|
||||||
Currently, no overwrite is set. Url from well-known or config is used.
|
Currently, no overwrite is set. Url from well-known or config is used.
|
||||||
</span>
|
</span>
|
||||||
@@ -237,10 +273,10 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
class="_container_1ug7n_10"
|
class="_container_1ug7n_10"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
aria-describedby="radix-_r_9_ radix-_r_b_ radix-_r_d_"
|
aria-describedby="radix-_r_a_ radix-_r_c_ radix-_r_e_"
|
||||||
checked=""
|
checked=""
|
||||||
class="_input_1ug7n_18"
|
class="_input_1ug7n_18"
|
||||||
id="radix-_r_8_"
|
id="radix-_r_9_"
|
||||||
name="_r_0_"
|
name="_r_0_"
|
||||||
title=""
|
title=""
|
||||||
type="radio"
|
type="radio"
|
||||||
@@ -256,13 +292,13 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
class="_label_19upo_59"
|
class="_label_19upo_59"
|
||||||
for="radix-_r_8_"
|
for="radix-_r_9_"
|
||||||
>
|
>
|
||||||
Legacy: state events & oldest membership SFU
|
Legacy: state events & oldest membership SFU
|
||||||
</label>
|
</label>
|
||||||
<span
|
<span
|
||||||
class="_message_19upo_85 _help-message_19upo_91"
|
class="_message_19upo_85 _help-message_19upo_91"
|
||||||
id="radix-_r_9_"
|
id="radix-_r_a_"
|
||||||
>
|
>
|
||||||
Compatible with old versions of EC that do not support multi SFU
|
Compatible with old versions of EC that do not support multi SFU
|
||||||
</span>
|
</span>
|
||||||
@@ -278,9 +314,9 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
class="_container_1ug7n_10"
|
class="_container_1ug7n_10"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
aria-describedby="radix-_r_9_ radix-_r_b_ radix-_r_d_"
|
aria-describedby="radix-_r_a_ radix-_r_c_ radix-_r_e_"
|
||||||
class="_input_1ug7n_18"
|
class="_input_1ug7n_18"
|
||||||
id="radix-_r_a_"
|
id="radix-_r_b_"
|
||||||
name="_r_0_"
|
name="_r_0_"
|
||||||
title=""
|
title=""
|
||||||
type="radio"
|
type="radio"
|
||||||
@@ -296,13 +332,13 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
class="_label_19upo_59"
|
class="_label_19upo_59"
|
||||||
for="radix-_r_a_"
|
for="radix-_r_b_"
|
||||||
>
|
>
|
||||||
Compatibility: state events & multi SFU
|
Compatibility: state events & multi SFU
|
||||||
</label>
|
</label>
|
||||||
<span
|
<span
|
||||||
class="_message_19upo_85 _help-message_19upo_91"
|
class="_message_19upo_85 _help-message_19upo_91"
|
||||||
id="radix-_r_b_"
|
id="radix-_r_c_"
|
||||||
>
|
>
|
||||||
Compatible with homeservers that do not support sticky events (but all other EC clients are v0.17.0 or later)
|
Compatible with homeservers that do not support sticky events (but all other EC clients are v0.17.0 or later)
|
||||||
</span>
|
</span>
|
||||||
@@ -318,9 +354,9 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
class="_container_1ug7n_10"
|
class="_container_1ug7n_10"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
aria-describedby="radix-_r_9_ radix-_r_b_ radix-_r_d_"
|
aria-describedby="radix-_r_a_ radix-_r_c_ radix-_r_e_"
|
||||||
class="_input_1ug7n_18"
|
class="_input_1ug7n_18"
|
||||||
id="radix-_r_c_"
|
id="radix-_r_d_"
|
||||||
name="_r_0_"
|
name="_r_0_"
|
||||||
title=""
|
title=""
|
||||||
type="radio"
|
type="radio"
|
||||||
@@ -336,13 +372,13 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
class="_label_19upo_59"
|
class="_label_19upo_59"
|
||||||
for="radix-_r_c_"
|
for="radix-_r_d_"
|
||||||
>
|
>
|
||||||
Matrix 2.0: sticky events & multi SFU
|
Matrix 2.0: sticky events & multi SFU
|
||||||
</label>
|
</label>
|
||||||
<span
|
<span
|
||||||
class="_message_19upo_85 _help-message_19upo_91"
|
class="_message_19upo_85 _help-message_19upo_91"
|
||||||
id="radix-_r_d_"
|
id="radix-_r_e_"
|
||||||
>
|
>
|
||||||
Compatible only with homservers supporting sticky events and all EC clients v0.17.0 or later
|
Compatible only with homservers supporting sticky events and all EC clients v0.17.0 or later
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -129,6 +129,11 @@ export const alwaysShowIphoneEarpiece = new Setting<boolean>(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const enableExtendedLivekitLogs = new Setting<boolean>(
|
||||||
|
"extended-livekit-logs",
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
export enum MatrixRTCMode {
|
export enum MatrixRTCMode {
|
||||||
Legacy = "legacy",
|
Legacy = "legacy",
|
||||||
Compatibility = "compatibility",
|
Compatibility = "compatibility",
|
||||||
|
|||||||
Reference in New Issue
Block a user